又出现问题了
#include <iostream>
#include <string>
using namespace std;
typedef struct node
{
string c[3];
}node;
class A
{
node n;
public:
A()
{
n.c[3]={"我","你","他"};
}
};
int main()
{
A aa;
system("pause");
return 0;
}
错误提示:
14 G:\temp\未命名.cpp expected primary-expression before '{' token
14 G:\temp\未命名.cpp expected `;' before '{' token
就是我定义了那个数组,想在构造函数中初始化,结果出错了.请问高手为什么?谢谢!
[解决办法]
请一个个赋值。数组没有这种赋值方式
[解决办法]
不可以那样初始化吧。
[解决办法]
一个个赋值吧:
A()
{
n.c[0]="我";
n.c[1]="你";
n.c[2]="他";
}