为什么具有相同名称但签名不同的多重继承函数不会被视为重载函数?
下面的代码片段在编译过程中会产生一个“foo的foo调用”错误,我想知道如果没有完全限定对foo的调用,是否有任何方法解决这个问题:
#include <iostream>struct Base1{
void foo(int){
}};struct Base2{
void foo(float){
}};struct Derived : public Base1, public Base2{};int main(){
Derived d;
d.foo(5);
std::cin.get();
return 0;}所以,问题就像标题所说的那样。想法?我的意思是,以下工作完美无瑕:
#include <iostream>struct Base{
void foo(int){
}};struct Derived : public Base{
void foo(float){
}};int main(){
Derived d;
d.foo(5);
std::cin.get();
return 0;}潇湘沐
相关分类