回复 2楼 苍穹之舞
你是哪个环境运行的?VC 2012么?
程序代码:
class Shit
{
private:
int i=4;
public:
Shit(int i=3): i(i++) {}
void display()
{
count << this->i;
}
};
我的Linux报错:
error: ISO C++ forbids initialization of member ‘i’
error: making ‘i’ static
ISO C++ forbids in-class initialization of non-const static member ‘i’
In constructor ‘Shit::Shit(int)’: ‘int Shit::i’ is a static data member; it can only be initialized at its definition
In member function ‘void Shit::display()’: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<<’