VC++6.0类初始化问题,下面的代码在6.0中编译通不过在GCC中就可以

#include
#include

using std::string;
using std::cout;
using std::endl;
class Student{
int n;
string name;
public:
Student( int num, string m) : n(num), name( m )
{
}
void display( void )
{
cout << n << endl;
cout << name << endl;
}
};
int main( void )
{
Student *p = new Student[3]{{1,"xx"},{2,"yy"},{3,"zz"}};

for ( int i = 0; i < 3; i++ )
p[i].display();

delete[] p;

return 0;
}

具体什么错误 不同编译器有一些语法区别等

Student *p = new Student[3]{{1,"xx"},{2,"yy"},{3,"zz"}};

这句话用的是C++11的语法,VC++6.0的编译环境应该是C++98标准,所以通不过。你可以换VS2012以上的版本试试。