#ifndef CLASS1_H
#define CLASS1_H
class A{
public:
int a = 1;
int f(){return a;}
int g(){return b;}
int h(){return c;}
protected:
int b = 2;
private:
int c = 3;
};
class B : public A{//访问说明符对派生类成员访问基类成员无影响(类内访问),,影响派生类用户 (类外访问)对基类的访问
public:
int f1(){return a;}
int g1(){return b;}//派生类可以直接访问基类protected
// int h1(){return c;}//派生类不能直接访问基类private
int h11(){return h();}//派生类能间接访问基类private
int a1 = 10;
protected:
int b1 = 20;
private:
int c1 = 30;
};
class C : protected A{//访问说明符对派生类成员访问基类成员无影响(类内访问),,影响派生类用户 (类外访问)对基类的访问
public:
int f2(){return a;}
int g2(){return b;}//派生类可以直接访问基类protect
//int h2(){return c;}//派生类不能直接访问基类private
int h22(){return h();}//派生类能间接访问基类private
int a2 = 100;
protected:
int b2 = 200;
private:
int c2 = 300;
};
class D : private A{//访问说明符对派生类成员访问基类成员无影响(类内访问),,影响派生类用户 (类外访问)对基类的访问
public:
int f3(){return a;}
int g3(){return b;}//派生类可以直接访问基类protect
//int h3(){return c;}//派生类不能直接访问基类private
int h33(){return h();}//派生类能间接访问基类private
int a3 = 1000;
protected:
int b2 = 2000;
private:
int c2 = 3000;
};
#endif // CLASS1_H
#ifndef CLASS1_H#define CLASS1_Hclass A{public: int a = 1; int f(){return a;} int g(){return b;} int h(){return c;} protected: int b = 2; private: int c = 3;};cl...