继承语法

减少代码的重复

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

class BasePage
{
public:
    void Header()
    {
        cout << "公共头部" << endl;
    }
};

class News : public BasePage
{

};

void test01()
{
    News news;
    news.Header();
}

int main()
{
    test01();
    system("Pause");
    return 0;
}

结果:

原文地址:https://www.cnblogs.com/yifengs/p/15176123.html