#include<iotream>
using namespace std;
class Person
{
public:
Person()
{
cout << "Person()" << endl;
}
Person(char a)
{
sexy=a;
cout << "Person(char a)" << endl;
}
void info()
{
cout << "sexy=" << sexy << endl;
}
private:
char sexy;
};
class Student:public Person
{
public:
Student()
{
cout << "Student()" << endl;
}
Student(string a,int b,char c):Person(c)
{
name =a;
age =b;
}
void info()
{
cout << "name=" << name << "\n" << "age=" << age << endl;
}
private:
string name;
int age;
};
int main()
{
Student stu("zhangsan",18,'f');
stu.info();
stu.Person::info();
//注意格式,不是Person::stu.info();否则会提示stu is not a member of ‘Person’
return 0;
}