注册 登录
编程论坛 C++教室

继承问题,大侠帮忙

elf6530789 发布于 2010-05-16 20:53, 467 次点击
#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

只有本站会员才能查看附件,请 登录


[ 本帖最后由 elf6530789 于 2010-5-16 21:42 编辑 ]
1 回复
#2
yc25757572010-05-16 21:36
好多乱码,lz还是打个包发上吧~~呵呵~~我这里好多错误。。vc++6.0~~
1