c++,这是错误显示:error C2059: syntax error : 'string',请问哪里错了?

#include<iostream>
using namespace std;

class BusinessManager
{
private:
char id[10];
char name[10];
int age;
public:
BusinessManager(char s1[10],char s2[10],int s3)
{
*strcpy(id,s1);
*strcpy(name,s2);
age = s3;
cout<<"Position:BusinessManager id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by constructor."<<endl;
}
~BusinessManager()
{
cout<<"Position:BusinessManager id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by destructor."<<endl;
}
};

class TechnicalManager
{
private:
char id[10];
char name[10];
int age;
public:
TechnicalManager(char s1[10],char s2[10],int s3)
{
*strcpy(id,s1);
*strcpy(name,s2);
age = s3;
cout<<"Position:TechnicalManager id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by constructor."<<endl;
}
~TechnicalManager()
{
cout<<"Position:TechnicalManager id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by destructor."<<endl;
}
};

class Employee
{
private:
char id[10];
char name[10];
int age;
public:
Employee(char s1[10],char s2[10],int s3)
{
*strcpy(id,s1);
*strcpy(name,s2);
age = s3;
cout<<"Position:Employee id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by constructor."<<endl;
}
~Employee()
{
cout<<"Position:TechnicalManager id:"<<id<<" name:"<<name<<" age:"<<age<<"This is printed by destructor."<<endl;
}
};

class Team
{
public:
Team();
private:
BusinessManager businessManager1("123","John",43);
TechnicalManager technicalManager1("234","Peter",42);
Employee employee1("345","James",32);
Employee employee2("456","Paul",23);
Employee employee3("567","Mary",27);
Employee employee4("678","Lily",31);
Employee employee5("789","Lucy",25);
};

int main()
{
Team team1;
return 0;
}

BusinessManager businessManager1("123","John",43);
TechnicalManager technicalManager1("234","Peter",42);
Employee employee1("345","James",32);
Employee employee2("456","Paul",23);
Employee employee3("567","Mary",27);
Employee employee4("678","Lily",31);
Employee employee5("789","Lucy",25);
你的这段代码有问题。因为还是在申明变量,并没有进行初始化,初始化要么放在构造函数中,或者调用特定的初始化函数,但是在申明变量的时候一定不能这样中,因为team还没有确定,怎么能够确定他的成员呢!!打个比方,没有确定母体,就确定了母体的孩子,这是不可能的
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-11
语法错误。要么是
string
标识不正确,要么就是string头文件没有包含进去
第2个回答  2011-05-22
建议把char类型改为string 很久没碰c++了不确定。
第3个回答  2011-05-22
#include <string >
第4个回答  2015-10-04
String 应该是大写的八