Can't define ++ operator in C++, what's the issue here?

后端 未结 3 837
终归单人心
终归单人心 2021-01-24 07:30

I\'m working through Bjarne Stroustrup\'s The C++ Programming Language and I\'m stuck on one of the examples. Here\'s the code, and aside from whitespace differences and comment

3条回答
  •  一整个雨季
    2021-01-24 08:07

    Traffic_light& operator++(Traffic_light& t) is a function with name operator ++. Each function shall be defined outside any other function. So place the definition of the operator before main.

提交回复
热议问题