#include <iostream>
class base
{
public:
base():a(10),b(20),c(30),d(40){};
~base(){};
int getC(){return c;};
int getAandB(){return a+b;};
protected:
int a;
int b;
private: //私有成员只能本类函数访问,继承的类的函数也不能访问
int c;
int d;
};
class inheritance:public base
{
public:
int getA(){ return a;}; //基类保护成员派生类函数可访问
//int getD(){return d;};
class base
{
public:
base():a(10),b(20),c(30),d(40){};
~base(){};
int getC(){return c;};
int getAandB(){return a+b;};
protected:
int a;
int b;
private: //私有成员只能本类函数访问,继承的类的函数也不能访问
int c;
int d;
};
class inheritance:public base
{
public:
int getA(){ return a;}; //基类保护成员派生类函数可访问
//int getD(){return d;};
};
base b;
//cout<<b.d<<endl; 对象不能访问私有成员
//cout<<b.a<<endl; 对象不能访问保护成员