error: max(int,int) in ComputeClass cannot implement max(int,int) in Compute
时间: 2024-05-29 08:13:17 浏览: 17
Class. How to fix this error?
To fix this error, you can try changing the name of one of the max functions, for example, to max_int, to avoid the naming conflict. Another solution is to use namespaces to differentiate between the two functions.
相关问题
error: divide() in Complex cannot implement divide() in Computable void divide(){ ^ attempting to assign weaker access privileges; was public
这个错误是因为在类 `Complex` 中定义的 `divide()` 函数的访问修饰符是 `public`,而在类 `Computable` 中定义的 `divide()` 函数的访问修饰符是更弱的 `protected` 或 `private`。因为在派生类中,重载的成员函数的访问权限不能比基类中更宽松。所以你需要将类 `Complex` 中的 `divide()` 函数的访问修饰符改为 `protected` 或 `private`,以匹配类 `Computable` 中的访问修饰符。
error: divide() in Complex cannot implement divide() in Computable private void divide(){ ^ attempting to assign weaker access privileges; was public
这个错误是因为在类 `Complex` 中定义的 `divide()` 函数的访问修饰符是更强的 `private`,而在类 `Computable` 中定义的 `divide()` 函数的访问修饰符是更弱的 `protected` 或 `public`。因为在派生类中,重载的成员函数的访问权限不能比基类中更严格。所以你需要将类 `Computable` 中的 `divide()` 函数的访问修饰符改为 `private`,以匹配类 `Complex` 中的访问修饰符。或者你也可以将类 `Complex` 中的 `divide()` 函数的访问修饰符改为 `protected` 或 `public`,以匹配类 `Computable` 中的访问修饰符。