定义必须采用的父函数
Define which parent function has to be taken
我有一个子类,它派生自两个父类(一个公共类,一个私有类)。每个父类都有一个重载运算符*的函数。如果我在子类中使用此函数,则会出现错误(不明确的函数),但是我想使用公共父级的方法。
class ParentA
{
public:
ParentA operator*(const ParentA & other);
};
class ParentB
{
public:
ParentB operator*(const ParentB & other);
};
class Child : public ParentA, private ParentB
{
...
};
int main()
{
Child x,y;
x*y;
return 0;
}
如何解决此问题?
谢谢雷莫
尝试按如下方式编写子类(未经测试):
class Child : public ParentA, private ParentB {
public:
using ParentA::operator*;
... /*same as before*/
};
相关文章:
- 不同翻译单元中不可重载的非内联函数定义
- Visual Studio中的函数声明和函数定义问题
- 编写代码时C++出现错误:错误 1 错误 C2601:'circle':本地函数定义是非法的
- 具有enable_if外部类原型的模板类构造函数定义
- 类的前向声明之后的类成员函数定义,在类声明之前
- 为函数定义符号不明确的指针参数
- C++模板专用化 - 无法匹配函数定义
- 错误:在第 6 行'{'标记之前,此处不允许使用函数定义
- 找不到 #define 的函数定义
- 根据类型特征更改函数定义?
- 将抽象基类中的所有纯虚函数定义为 varaidaic 模板
- 命名空间更改函数定义
- "Type&"与C++函数定义中的"Type*"
- C++:为什么允许在另一个函数中声明函数,而不允许在函数定义中声明?
- 如何从 C++ 中的现有模板函数定义新函数
- 私有在函数定义/实现的返回值范围内是什么意思 (c++)?
- 越界成员函数定义是否需要一个完全限定的类名,直到全局范围
- 为什么c++允许成员函数定义中实例的私有成员访问
- Qt基类函数定义
- C++函数定义中参数列表后面额外一对括号的含义