继承问题,大侠帮忙
#include <iostream>#include <cstring>
using namespace std;
class teac{
protected:
char name[20];
char sex;
int num;
};
teac::teac(char nam[],char se,int nu)
{
strcpy(name,nam);
sex=se;
num=nu;}
void teac::show()
{
cout<<"name="<<name<<endl;
cout<<"sex="<<sex<<endl;
cout<<"num="<<num<<endl;
}
class bir{
int y;
int m;
int d;
public:
bir(int y,int m,int d)
{ y=y; m=m;d=d;}
void change(int a,int b, int c)
{y=a; m=b; d=c;}
void show1{
cout<<a<<"骞?<<b<<"鏈?<<c<<"鍙?<<endl;
}
};
class pro:public teac{
double ye;
bir b;
public:
pro(char name[],char sex,int num,int y,int m, int d,double ye):
teac(name[],sex,num),b(y,m,d),ye(ye)
void change(int y, int m, int d)
{ b.change(y,m,d);}
void display()
{ cout<<teac::show();
cout<<b.show1;
cout<<ye<<endl; }
};
int main()
{
pro p("鐚?叓鎴?,'f',10,1987,8,25,25.6);
p.display();
p.change(1988,3,25);
p.display();
return 0;
}
其中浙一句报错 pro(char name[],char sex,int num,int y,int m, int d,double ye):
teac(name[],sex,num),b(y,m,d),ye(ye),报错信息为expert primary express before [ token
2.rar
(882 Bytes)
[ 本帖最后由 elf6530789 于 2010-5-16 21:42 编辑 ]