[size=18.6667px]国庆,老师布置如下题目:
class B: public A {
• public:
• void print()
• { cout << "hello" << endl; }
•};
•
•B test;
•
••把上面的程序补充完整,使之能正确运行。并能输出如下的结果
hello
•说明:
•1. 不允许再修改类B的定义
•2. 你补充的部分不能再出现类名 B。如 B b1; 使用了B,不符合要求。
•3. 也不能有直接输出语句 cout << "hello" ,而是要想办法让类B里面的print() 执行。
4.自己写的内容中也不能出现对象名test
据现学基础,觉得题目不能基类引用和指针调用,也不能直接通过B类对象调用,怎么办??


雷达卡



京公网安备 11010802022788号







