c++公有有继承,并且final 继承的类不可再次继承

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/TH_NUM/article/details/89502609
//
// Created by wuyongyu on 2019/4/24.
//

#include <iostream>
#include <cstring>


using namespace std;

class Route{

    public:

    void Route_Func(){

        cout<<"this is Route func"<<endl;
    }
    class Service{
        virtual void SayHello(){
            cout<<"hello"<<endl;
        }
    };
};
class route final: public Route::Service{
public:

    void SayHello() override{
        cout<<"override hello"<<endl;
    }

};

//class route2 :public route{  // Error : route class is final
    
//};
int main()
{

    ::route service;

    service.SayHello();
    
    return 0;

}

更多的公有,私有,保护继承参考:https://www.cnblogs.com/yyxt/p/4243587.html

展开阅读全文

没有更多推荐了,返回首页