public继承方式
/*
* @Author: sottxiong
* @Date: 2019-11-20 13:12:49
* @Last Modified by: sottxiong
* @Last Modified time: 2019-11-20 13:17:12
*/
#include <iostream>
//艺人类
class Artist
{
public:
char name[8];
protected:
int age;
private:
double fee;//出场费
};
class Singer:public Artist
{
public:
void sing(std::string name){
name="麦当啦";//子类不可以访问父类的public成员
age=22; //子类可以访问父类的protected成员
// fee=100000; //子类不可以访问父类的private成员
}
};
int main(int argc, char const *argv[])
{
Singer singer;
singer.sing("hello");
return 0;
}