且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在 C++ 中定义 ++ 运算符,这里有什么问题?

更新时间:2023-11-10 18:50:04

Traffic_light&operator++(Traffic_light& t) 是一个名为 operator++ 的函数.每个功能都应在任何其他功能之外定义.所以把操作符的定义放在main之前.

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.