Hey Kup, can I ask for some help?
PostPosted:Thu Jun 23, 2005 2:43 pm
One of two things that I'd managed to miss in my C++ learning is how a method in a derived class that uses the override keyword differs from one that doesn't - e.g.:
What I don't get is exactly what the override keyword does. What difference does the override keyword make? Is it only for linking purposes?
Code: Select all
My understanding is that whether or not you specify the override keyword in declaring Doofus::JibberJabber, a call to Doofus::JibberJabber will override the implementation declared in Dorkus::JibberJabber - so, you'll get "I pity da fool who don' stop his jibba-jabba!" as output. If you want to call the base class code, you can put an explicit call to Dorkus::JibberJabber in the implementation of Doofus::JibberJabber. class Dorkus
{
public void JibberJabber()
{
cout << "Quit yo' jibba-jabba!";
}
}
class Doofus: public Dorkus
{
public override void JibberJabber()
{
cout << "I pity da fool who don' stop his jibba-jabba!";
}
}
What I don't get is exactly what the override keyword does. What difference does the override keyword make? Is it only for linking purposes?