error C2629: unexpected 'class Teacher ('
#include<iostream>#include<string>usingnamespacestd;classTeacher{public:Teacher(strin...
#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
Teacher (string n,int a1,char s,string a2,stirng p,string t);
void display();
protected:
string name;
int age;
char sex;
string addr;
string phnnum;
string title;
};
Teacher::Teacher(string n,int a1,char s,string a2,stirng p,string t)
:name(n),age(a1),sex(s),addr(a2),phnnum(p),title(t)
{
}
Teacher::display()
{
cout<<"name:"<< name <<endl;
cout<<"age:"<< age <<endl;
cout<<"sex:"<< sex <<endl;
cout<<"addr:"<< addr <<endl;
cout<<"phnnum:"<< phnnum <<endl;
cout<<"title:"<< title <<endl;
}
class Cadre
{
public:
Cadre(string n,int a1,char s,string a2,stirng p,string t);
void display();
protected:
string name;
int age;
char sex;
string addr;
string phnnum;
string post;
};
Cadre::Cadre(string n,int a1,char s,string a2,stirng p,string t)
:name(n),age(a1),sex(s),addr(a2),phnnum(p),post(t)
{
}
Cadre::display()
{
cout<<"name:"<< name <<endl;
cout<<"age:"<< age <<endl;
cout<<"sex:"<< sex <<endl;
cout<<"addr:"<< addr <<endl;
cout<<"phnnum:"<< phnnum <<endl;
cout<<"post:"<< post <<endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string n,int a1,char s,string a2,stirng p,string t,string p,float wage);
display_1();
private:
float wage;
};
Teacher_Cadre::Teacher_Cadre(string n,int a1,char s,string a2,stirng p,string t,string p,float wage)
:
name(n),age(a1),sex(s),addr(a2),phnnum(p),title(t),post(p),wage(w)
{
}
Teacher_Cadre::display_1()
{
Teacher::display();
cout<<"post"<< post <<endl;
cout<<"wage"<< wage <<endl;
}
int int main( )
{
Teacher_Cadre A("张三",30,m,"四平路1239号","1234567","老师","你猜","1234.5")
A.display_1();
return 0;
} 展开
#include <string>
using namespace std;
class Teacher
{
public:
Teacher (string n,int a1,char s,string a2,stirng p,string t);
void display();
protected:
string name;
int age;
char sex;
string addr;
string phnnum;
string title;
};
Teacher::Teacher(string n,int a1,char s,string a2,stirng p,string t)
:name(n),age(a1),sex(s),addr(a2),phnnum(p),title(t)
{
}
Teacher::display()
{
cout<<"name:"<< name <<endl;
cout<<"age:"<< age <<endl;
cout<<"sex:"<< sex <<endl;
cout<<"addr:"<< addr <<endl;
cout<<"phnnum:"<< phnnum <<endl;
cout<<"title:"<< title <<endl;
}
class Cadre
{
public:
Cadre(string n,int a1,char s,string a2,stirng p,string t);
void display();
protected:
string name;
int age;
char sex;
string addr;
string phnnum;
string post;
};
Cadre::Cadre(string n,int a1,char s,string a2,stirng p,string t)
:name(n),age(a1),sex(s),addr(a2),phnnum(p),post(t)
{
}
Cadre::display()
{
cout<<"name:"<< name <<endl;
cout<<"age:"<< age <<endl;
cout<<"sex:"<< sex <<endl;
cout<<"addr:"<< addr <<endl;
cout<<"phnnum:"<< phnnum <<endl;
cout<<"post:"<< post <<endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string n,int a1,char s,string a2,stirng p,string t,string p,float wage);
display_1();
private:
float wage;
};
Teacher_Cadre::Teacher_Cadre(string n,int a1,char s,string a2,stirng p,string t,string p,float wage)
:
name(n),age(a1),sex(s),addr(a2),phnnum(p),title(t),post(p),wage(w)
{
}
Teacher_Cadre::display_1()
{
Teacher::display();
cout<<"post"<< post <<endl;
cout<<"wage"<< wage <<endl;
}
int int main( )
{
Teacher_Cadre A("张三",30,m,"四平路1239号","1234567","老师","你猜","1234.5")
A.display_1();
return 0;
} 展开
2个回答
展开全部
(1)class Person::public Teacher,public Cadre
Person后面是:不是::
(2)class Cadre
{public:
Cadre(string nam,int a,char s,string p,string ad,string t);
void display();
protected:
string name;
ine age; // 改成int age;
(3)如果你的C++是VisualStudio2002以后的版本
前面2行改成:
#include<string>
#include <iostream>
using namespace std;
这样改后在我的visual studio 2010上没有问题了
打字不易,如满意,望采纳。
Person后面是:不是::
(2)class Cadre
{public:
Cadre(string nam,int a,char s,string p,string ad,string t);
void display();
protected:
string name;
ine age; // 改成int age;
(3)如果你的C++是VisualStudio2002以后的版本
前面2行改成:
#include<string>
#include <iostream>
using namespace std;
这样改后在我的visual studio 2010上没有问题了
打字不易,如满意,望采纳。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询