1.继承的基本语法
#include<iostream>
using namespace std;
class BasePage
{
public:
void header() {
cout << "首页、公开课、登录、注册..." << endl;
}
void footer() {
cout << "帮助中心、交流合作、站内地图..." << endl;
cout << "————————————————" << endl;
}
void left() {
cout << "Java、Python、C++..." << endl;
}
};
class Java :public BasePage
{
public:
void content() {
cout << "Java学科视频" << endl;
}
};
class CPP :public BasePage
{
public:
void content() {
cout << "C++学科视频" << endl;
}
};
class Python :public BasePage
{
public:
void content() {
cout << "Python学科视频" << endl;
}
};
void test() {
Java j;
j.header();
j.left();
j.content();
j.footer();
CPP c;
c.header();
c.left();
c.content();
c.footer();
Python p;
p.header();
p.left();
p.content();
p.footer()