我有两个类:CPP多态性和继承 - 编译器没有发现方法
template<typename T>
class A{
public:
T& someMethod(std::string);
}
template<typename T>
class B: public A<T>{
public:
T& someMethod(T&,T&);
}
我的问题是,知道我不能叫
B b;
b.someMethod("HelloWorld");
,因为我的编译器看不到someMethod(std::string)
。你知道为什么这样吗?
重复http://stackoverflow.com/questions/411103/function-with-same-name-but-different-signature-in-derived-class – Sasha
我想补充说 ** B b; b.someMethod(“HelloWorld”); ** 表明您根本没有使用多态,只有继承 – Guiroux
在提供的示例中没有多态。 – SergeyA