- 原题题目
- 代码实现
- 提交结果
原题题目
代码实现
#include
using namespace std;
class BaseClass {
public:
void fn1() const { cout << "BaseClass:fn1()" << endl; }
void fn2() const { cout << "BaseClass:fn2()" << endl; }
};
class DerivedClass : public BaseClass {
public:
void fn1() const { cout << "DerivedClass:fn1()" << endl; }
void fn2() const { cout << "DerivedClass:fn2()" << endl; }
};
int main()
{
DerivedClass dc;
BaseClass *pb = &dc;
DerivedClass *pd = &dc;
dc.fn1();
dc.fn2();
pb->fn1();
pb->fn2();
pd->fn1();
pd->fn2();
}
提交结果
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)