有没有办法直接公开父类的一些私有方法。 在下面的例子中,如果我有一个Child类型的对象,我想能够直接调用其父类的方法a(),但不是b(); 当前的解决方案会产生很多样板代码,特别是如果有很多参数。
class Parent {
public:
void a(int p1, double p2, int p3, std::vector <int> &p4);
void b();
};
class Child : private Parent {
public:
void a(int p1, double p2, int p3, std::vector <int> &p4) {
Parent::a(p1, p2, p3, p4);
}
};