include <iostream>
using namespace std;
//更改属性 形式 using 类1 :: 成员
//private protected 不能更改
class People;
class Student;
class People{
public:
void show();
protected:
char *m_name;
int m_age;
};
void People::show(){
cout<<m_name<<"的年龄是"<<m_age<<endl;
}
class Student :public People{
public:
void learn();
void ceshi(*pstu);
public:
using People ::m_name; // 将People 类两个成员protected改为 public
using People ::m_age;
float m_score;
private:
using People ::show; // 将People 类show成员改为private
};
void Student ::learn(){
cout<<m_name<<m_age<<m_score<<endl;
}
void main(){
class Student stu;
stu.m_name="mark";
stu.m_age=19;
stu.m_score=90;
stu.learn();
// Student.show(); 报错
}