这样比较好:
#include<iostream.h>
class father{
char a[100];
public:
father(){cout<<"输入父亲姓名:"<<endl;cin>>a;}
void outputName(){cout<<"父亲姓名:"<<a<<endl;}
};
class mother{
char b[100];
public:
mother(){cout<<"输入母亲姓名:"<<endl;cin>>b;}
void outputName(){cout<<"母亲姓名:"<<b<<endl;}
};
class child:public father,public mother{
char c[100];
public:
child(){cout<<"输入孩子姓名:"<<endl;cin>>c;}
void outputName(){ father::outputName(); mother::outputName();cout<<"孩子姓名:"<<c<<endl;}
};
void main(){
child d1;
d1.outputName();
}