公用继承纠错
#include<iostream.h>#include<string.h>
class student
{public:
void get_value()
{cin>>num>>name>>sex;}
void display()
{cout<<"num:"<<num<<endl;
cout<<"name:"<<name<<endl;
cout<<"sex:"<<sex<<endl;
private:
int num;
string name;
char sex;
};
class student1:public student
{public:
void display_1()
{
cout<<"age:"<<age<<endl;
cout<<"address:"<<address<<endl;
private:
int age;
string address;
};
int main()
{student std1;
std1.get_value();
std1.display();
student1 std2(18,"henan");
std2.display_1();
return 0;
}
哪位兄弟帮忙看下,出了什么问题?谢谢了!