c++虚函数

来源:互联网 发布:买司考音频淘宝哪家好 编辑:程序博客网 时间:2024/05/18 01:49
#include<iostream>
using namespace std;
class C
{
    public:
        void funcA(){
            cout<<"this is c funcA"<<endl;
            funcB();
        }
        virtual void funcB()=0;
    
};
class B : public C
{
    public:
        void funcB(){
            cout<<"this is B funcB"<<endl;
        }
};
int main()
{
    B b;
    b.funcA();
    return 0;

}



//在funcA中调用的是B类的funcB()

原创粉丝点击