#include "stdafx.h" #include <iostream> #include <algorithm>using namespace Std;class base{public:int num; virtual void func () {cout<< "Do Something in Base" <<endl;}}; Class Derived:private base{public:derived (int i)/*:num (i) *///this is not possible, here is the initialization, and NUM has been initialized in the parent class {num=i;//So can, here is the assignment} virtual void func () {cout<< "num=" <<num<<endl;cout<< "do Something in Derived" << Endl;} Public:using base::num;//restore Access property public:friend void getbaseptr (void);}; void Getbaseptr (void) {base* pb=new Derived) <span style= "White-space:pre" ></span>//so it's okay pb-> Func ();} int main () {//base* pb=new Derived () <span style= "White-space:pre" ></span>//after using the private and protected inheritance properties , it is not possible to assign a value//because base is already a private part of derived and cannot be accessed here//So it cannot complete the conversion getbaseptr (); System ("pause"); return 0;}