Ask question, find answer on any topic in real time from people around the world. Have a question ? Ask now. Know an Answer share your Knowledge to world.PrepJunk is the online community that has Junk of answers!
UNITED STATES
1
LEBANON
1
2
online

What is a ‘virtual member function’?

0

What is a ‘virtual member function’?

asked Apr 7, 2012 in C++ by mohan (541 points)
    

1 Answer

0

A virtual member function is a member fn preceded by the keyword ‘virtual’.

It has the effect of allowing derived classes to replace the implementation of the fn. Furthermore the replacement is always called whenever the object in question is actually of the derived class. The impact is that algorithms in the base class can be replaced in the derived class without affecting the operation of the base class. The replacement can be either full or partial, since the derived class operation can invoke the base class version if desired.

This is discussed further below.

answered Apr 7, 2012 by mohan (541 points)