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

#include<iostream>usingnamespacestd;classBusinessManager{private:charid[10];charname[... #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;
}
展开
 我来答
cssalp
2011-05-22 · TA获得超过193个赞
知道小有建树答主
回答量:209
采纳率:0%
帮助的人:238万
展开全部
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还没有确定,怎么能够确定他的成员呢!!打个比方,没有确定母体,就确定了母体的孩子,这是不可能的
cgqlove
2015-11-11 · 贡献了超过113个回答
知道答主
回答量:113
采纳率:100%
帮助的人:16.6万
展开全部
语法错误。要么是
string
标识不正确,要么就是string头文件没有包含进去
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
lwy小艳
2011-05-22
知道答主
回答量:51
采纳率:0%
帮助的人:24.5万
展开全部
建议把char类型改为string 很久没碰c++了不确定。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
newuserbusycat
2011-05-22 · 超过10用户采纳过TA的回答
知道答主
回答量:18
采纳率:0%
帮助的人:0
展开全部
#include <string >
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友bea5943
2015-10-04 · 超过23用户采纳过TA的回答
知道答主
回答量:93
采纳率:0%
帮助的人:35.2万
展开全部
String 应该是大写的八
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(5)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式