#include "stdafx.h" #include#include using namespace std; class Base { public: int num; virtual void func() { cout<<"Do something in Base"< //这样就可以啦 pb->func(); } int main() { //Base* pb=new Derived(10); //使用private和protected的继承属性后,不可以这样赋值 //因为Base在Derived中已经是私有部分,不能在此处访问 //所以无法完成转换 getBasePtr(); system("pause"); return 0; }