首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

又出现有关问题了

2012-02-11 
又出现问题了#include iostream#include stringusing namespace stdtypedef struct node{string c[3]

又出现问题了
#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]="他";
}

热点排行