题目内容
请将如下程序补充完整,使程序的输出结果如下:Derived::Print: 5Derived destructorBase destructor源程序清单:#include using namespace std;class BaseClass{public:~BaseClass();virtual void Print();};BaseClass::~BaseClass(){cout<< "Base destructor" << endl; }void BaseClass::Print(){cout << "BaseClass::Print" << endl;}class Derived:BaseClass{public:Derived();~Derived();void Print();private:int *p;};Derived::Derived(){p =;}Derived::~Derived() {cout << "Derived destructor" << endl;delete p;}void Derived::Print(){cout << "Derived::Print: " <<*p<< endl;}void fun(BaseClass* b) {b->Print();delete b;}int main() {BaseClass *ptr = ;fun(ptr);return 0;}
查看答案
搜索结果不匹配?点我反馈
更多问题