Dado el siguiente ejemplo, ¿por qué tengo que utilizar explícitamente la instrucción b->A::DoSomething()
en lugar de solo b->DoSomething()
?Resolución de sobrecarga de C++
¿No debería la resolución de sobrecarga del compilador averiguar de qué método estoy hablando?
estoy usando Microsoft VS 2005. (Nota: el uso de Virtual no ayuda en este caso.)
class A
{
public:
int DoSomething() {return 0;};
};
class B : public A
{
public:
int DoSomething(int x) {return 1;};
};
int main()
{
B* b = new B();
b->A::DoSomething(); //Why this?
//b->DoSomething(); //Why not this? (Gives compiler error.)
delete b;
return 0;
}
Estoy tratando de llamar a DoSomething() en la clase A usando un puntero a la clase B. – Abe