// cqqtest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>

using namespace std;

class Virtual{
public:
    virtual void foo(){
        cout<<"Virtual"<<endl;
    }
};
class bbb: public Virtual{
public:
    void foo(){
        cout<<"bbb"<<endl;
    }
};

class ccc: public bbb{

private:
    void foo(){
        cout<<"ccc"<<endl;
    }
};


int _tmain(int argc, _TCHAR* argv[])
{

    Virtual &vt =ccc();
    vt.foo();//output "ccc"

    ccc &cc= ccc();

    cc.Virtual::foo();

    getchar();

    return 0;
}

相关文章:

  • 2021-09-10
  • 2022-12-23
  • 2021-04-25
  • 2021-09-07
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-08-25
  • 2021-10-03
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案