c++问题

刚刚学的C++,类的继承问题,麻烦高手帮忙看一下问题出在哪里?

 

#include <iostream.h>
#include<string.h>

class Teacher
{
public :
 Teacher( string nam,int ag,char se,int adr,int n,char tit);
 void display();
protected:
 string name;
 int age;
 char sex;
 int address;
 int num;
 char title;
};
Teacher::Teacher(string nam,int ag,char se,int adr,int n,char tit)
{
 name=nam; age=ag;
 sex=se; address=adr;
 num=n;  title=tit;
}
void Teacher::display()
{
 cout<<"name:"<<name<<endl;
 cout<<"age:"<<age<<endl;
 cout<<"sex:"<<sex<<endl;
 cout<<"title:"<<title<<endl;
 cout<<"address:"<<address<<endl;
    cout<<"num:"<<num<<endl;
}

class Cadre
{
public:
 Cadre(string nam,int ag,char se,int adr,int n,char p)
 void display();
protected:
 string name;
 int age;
 char sex;
 int address;
 int num;
 char post;

};
Cadre::Cadre(string nam,int ag,char se,int adr,int n,char p)
{
 name=nam; age=ag;
 sex=se; address=adr;
 num=n; post=p;
}
void Cadre::display()
{
 cout<<"name:"<<name<<endl;
 cout<<"age:"<<age<<endl;
 cout<<"sex:"<<sex<<endl;
 cout<<"post:"<<post<<endl;
 cout<<"address:"<<address<<endl;
    cout<<"num:"<<num<<endl;
}

class Teacher_Cadre:public Teacher,public Cadre
{
 Teacher_Cadre(string nam,int ag,char se,int adr,int n,char tit,char p,int w);
 void show();
protected:
 int wages;
};
Teacher_Cadre::Teacher_Cadre(string nam,int ag,char se,int adr,int n,char tit,char p,int w):
 Teacher(nam,ag,se,adr,n,tit),Cadre(nam,ag,adr,n,p),wages(w){}
 void Teacher_Cadre::show()
 {
  Teacher::display();
  cout<<"post:"<<post<<endl;
  cout<<"wages"<<wages<<endl;
 }

void main()
{
 Teacher_Cadre T_c("wang li",33,'s',101021,13539760892,'a','f',4500);
 T_c.show();

}

 

 

错误提示是:

Compiling...
1.cpp
C:/Documents and Settings/Administrator/1.cpp(7) : error C2629: unexpected 'class Teacher ('
C:/Documents and Settings/Administrator/1.cpp(7) : error C2238: unexpected token(s) preceding ';'
C:/Documents and Settings/Administrator/1.cpp(10) : error C2146: syntax error : missing ';' before identifier 'name'
C:/Documents and Settings/Administrator/1.cpp(10) : error C2501: 'string' : missing storage-class or type specifiers
C:/Documents and Settings/Administrator/1.cpp(10) : error C2501: 'name' : missing storage-class or type specifiers
C:/Documents and Settings/Administrator/1.cpp(17) : error C2065: 'string' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(17) : error C2146: syntax error : missing ')' before identifier 'nam'
C:/Documents and Settings/Administrator/1.cpp(17) : error C2350: 'Teacher::Teacher::Teacher' is not a static member
C:/Documents and Settings/Administrator/1.cpp(17) : error C2059: syntax error : ')'
C:/Documents and Settings/Administrator/1.cpp(18) : error C2143: syntax error : missing ';' before '{'
C:/Documents and Settings/Administrator/1.cpp(18) : error C2447: missing function header (old-style formal list?)
C:/Documents and Settings/Administrator/1.cpp(25) : error C2065: 'name' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(36) : error C2629: unexpected 'class Cadre ('
C:/Documents and Settings/Administrator/1.cpp(36) : error C2238: unexpected token(s) preceding ';'
C:/Documents and Settings/Administrator/1.cpp(39) : error C2146: syntax error : missing ';' before identifier 'name'
C:/Documents and Settings/Administrator/1.cpp(39) : error C2501: 'string' : missing storage-class or type specifiers
C:/Documents and Settings/Administrator/1.cpp(39) : error C2501: 'name' : missing storage-class or type specifiers
C:/Documents and Settings/Administrator/1.cpp(47) : error C2146: syntax error : missing ')' before identifier 'nam'
C:/Documents and Settings/Administrator/1.cpp(47) : error C2350: 'Cadre::Cadre::Cadre' is not a static member
C:/Documents and Settings/Administrator/1.cpp(47) : error C2059: syntax error : ')'
C:/Documents and Settings/Administrator/1.cpp(48) : error C2143: syntax error : missing ';' before '{'
C:/Documents and Settings/Administrator/1.cpp(48) : error C2447: missing function header (old-style formal list?)
C:/Documents and Settings/Administrator/1.cpp(53) : error C2039: 'display' : is not a member of 'Cadre'
        C:/Documents and Settings/Administrator/1.cpp(34) : see declaration of 'Cadre'
C:/Documents and Settings/Administrator/1.cpp(56) : error C2065: 'age' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(57) : error C2065: 'sex' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(58) : error C2065: 'post' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(59) : error C2065: 'address' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(60) : error C2065: 'num' : undeclared identifier
C:/Documents and Settings/Administrator/1.cpp(65) : error C2629: unexpected 'class Teacher_Cadre ('
C:/Documents and Settings/Administrator/1.cpp(65) : error C2238: unexpected token(s) preceding ';'
C:/Documents and Settings/Administrator/1.cpp(70) : error C2146: syntax error : missing ')' before identifier 'nam'
C:/Documents and Settings/Administrator/1.cpp(70) : error C2350: 'Teacher_Cadre::Teacher_Cadre::Teacher_Cadre' is not a static member
C:/Documents and Settings/Administrator/1.cpp(70) : error C2059: syntax error : ')'
C:/Documents and Settings/Administrator/1.cpp(71) : error C2199: syntax error : found 'Teacher (' at global scope (was a declaration intended?)
C:/Documents and Settings/Administrator/1.cpp(71) : error C2143: syntax error : missing ';' before '{'
C:/Documents and Settings/Administrator/1.cpp(71) : error C2447: missing function header (old-style formal list?)
C:/Documents and Settings/Administrator/1.cpp(81) : error C2661: 'Teacher_Cadre::Teacher_Cadre' : no overloaded function takes 8 parameters
C:/Documents and Settings/Administrator/1.cpp(82) : error C2248: 'show' : cannot access private member declared in class 'Teacher_Cadre'
        C:/Documents and Settings/Administrator/1.cpp(66) : see declaration of 'show'
执行 cl.exe 时出错.

1.obj - 1 error(s), 0 warning(s)

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值