定义一个基类Base,有两个公有成员函数fn1,fn2,私有派生出Derived类,如何通过Derived类的对象调用基类的函数fn1。
#include<bits/stdc++.h>
using namespace std;
class Base {
public:
int fn1() { return 0; }
int fn2() { return 0; }
};
class Derived: private Base {
public:
int fu1() {
return Base::fn1();
}
int fu2() {
return Base::fn2();
}
};
int main()
{
Derived d1;
d1.fu1();
d1.fu2();
}
标签:fn2,fn1,int,Derived,Base,基类
From: https://www.cnblogs.com/drip3775/p/17304113.html