Objectives :

Step: 1 Create a source file.

Step: 2 Edit the  source file

Step :3 Run Time View, note Derv1 and Derv2 displays corresponding objects with virtual function, as shown in the illustration Virt.exe.

Step: 4 Brief Discussion


Pointing a virtual function:

The functions "void show()" in the derived classes would display the strings like "Derv1 or Derv2". If we remove virtual keyword, the cursor will not fetch these functions, and the runtime views of this application will only print out, "Base", the string output of the function "void show()"  in the  "Base" class.