#include
#include
using namespace std;
class fa {
public:
int m = 1000;
void shuchu() {
cout << "fa类的shuchu对象"<
cout << "fa类的shuchu对象的int重载"<
public:
int m = 100;
void shuchu() {
cout << "son类的shuchu对象"<
son s;
cout << "同名成员属性处理方法" << endl;
cout << "son下 m=" << s.m << endl;
cout << "fa下 m=" << s.fa::m << endl;
cout << "同名成员函数处理方法" << endl;
cout << "son下的函数:" << endl;
s.shuchu();
cout << "nfa下的函数:" << endl;
s.fa::shuchu();//调用父类需要作用域
//s.shuchu(100);//报错
s.fa::shuchu(100);
}
int main() {
ceshi();
}
//cpp允许一个类继承多个类
#include
#include
using namespace std;
//cpp允许一个类继承多个类
//【实际开发不建议】
class fa_1 {
public:
int m1 = 1;
};
class fa_3 {
public:
int m3 = 3;
};
class fa_2 {
public:
int m2 =2;
};
class son :public fa_1, public fa_2, public fa_3 {
public:
int m2 = 4;
};
int main() {
son s;
cout << "sizeof = " << sizeof(s)<