【发布时间】:2014-05-06 02:54:51
【问题描述】:
说快六倍...为什么这在 MSVC 2010 中不能编译?
class A {
public:
void foo(int a, int b) { };
void foo(int a) { };
};
class B: public A {
public:
void foo(int a, int b) { }; // <-- comment this out to compile
};
int main(int argc, char* argv[])
{
B b;
b.foo(1); // <-- doesn't compile... shouldn't B just inherit this overload?
}
【问题讨论】:
-
你怎么这么快就找到了?我搜索了一会儿。不过我没有使用分辨率这个词。
-
我用谷歌搜索了“继承重载函数”。
-
感谢您的回答,这就是我所需要的。所以如果它是重复的,我该如何删除它?
-
您可以删除自己的问题,但如果它有一个赞成的答案或超过 1 个答案,则不能。
标签: c++ visual-c++ inheritance overriding overloading