class Base
{
public:
virtual void foo()
{}
};
class Derived: public Base
{
public:
virtual void foo()
{}
};
int main()
{
Base *pBase = NULL;
Base objBase;
Derived objDerived;
pBase = &objDerived;
pBase->foo();
/*Here Derived class foo will be called, but i want this to call
a base class foo. Is there any way for this to happen? i.e. through
casting or something?*/
}
views:
549answers:
3
+3
A:
You can do it through scope resolution operator ::
Something like this:
pBase->Base::foo()
Aamir
2009-07-16 08:53:18
+5
A:
Both responses above are correct...But be careful, if you need to do that, maybe you have a big problem about the conception or the design...
Matthieu
2009-07-16 08:58:27
You are right: essentially this implies you need two methods.
xtofl
2009-07-16 09:03:18