#include<iostream>
using namespace std;
class A
{
public:
A()
{
cout<<"A"<<endl;
}
void PublicCout() {cout<<"Apublic"<<endl;}
protected:
void ProtectedCout() {cout<<"Aprotected"<<endl;}
private:
void PrivateCout() {cout<<"Aprivate"<<endl;}
};
class B:public A //proteceted private 切换继承特性查看输出
{
public:
B()
{
cout<<"B"<<endl;
}
// void ProtectedCout() {cout<<"Bprotected"<<endl;}
};
void main()
{
B b;
b.PublicCout();
//b.ProtectedCout(); //调用保护的查看是否能输出
}
using namespace std;
class A
{
public:
A()
{
cout<<"A"<<endl;
}
void PublicCout() {cout<<"Apublic"<<endl;}
protected:
void ProtectedCout() {cout<<"Aprotected"<<endl;}
private:
void PrivateCout() {cout<<"Aprivate"<<endl;}
};
class B:public A //proteceted private 切换继承特性查看输出
{
public:
B()
{
cout<<"B"<<endl;
}
// void ProtectedCout() {cout<<"Bprotected"<<endl;}
};
void main()
{
B b;
b.PublicCout();
//b.ProtectedCout(); //调用保护的查看是否能输出
}