C++类定义中数组初始化问题(急)
操作系统:win2000和winxp。
编译环境:VC6.0
******************
#include <iostream.h>
class TestArray
{
private:
int Arr[3] = {1,2,3}; //?????
public:
void OutData()
{
for(int i = 0; i < 3; i ++)
cout << Arr[i] << endl;
}
};
void main()
{
TestArray myArray;
myArray.OutData();
}
******************
--------------------Configuration: array - Win32 Debug--------------------
Compiling...
array.cpp
E:\文档\MyProjects\CPP\array.cpp(6) : error C2059: syntax error : '{'
E:\文档\MyProjects\CPP\array.cpp(6) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
Error executing cl.exe.
array.exe - 2 error(s), 0 warning(s)
******************
为什么Arr[3] = {1,2,3}会有语法错误?在类的成员变量定义的同时用{}给数组初始化不行吗?