题目内容
请改正程序中的错误(在对应空处写出错误所在行的完整一行,分号不写),使程序的输出结果如下:BaseClassDerived1Derived2#include using namespace std;class BaseClass {public:/********** Error found【1】**********/void Print() const;};void BaseClass::Print() const {cout << "BaseClass" << endl;}/********** Error found【2】**********/class Derived1::BaseClass{ public:void Print() const;};void Derived1::Print() const {cout << "Derived1" << endl;}class Derived2: public Derived1 {public:void Print() const;};void Derived2::Print() const {cout << "Derived2" << endl;}void Print(BaseClass &p) {/********** Error found【3】**********/p->Print();}int main() {BaseClass b; Derived1 d1; Derived2 d2;Print(b); Print(d1); Print(d2);return 0;}
查看答案
搜索结果不匹配?点我反馈
更多问题