A Pointer and Virtual Function

The example program named VIRTUAL4.CPP is identical to the last program except for the addition of the keyword virtual to line 8 once again.

I hope you are not terribly disappointed to find that this program, including the keyword virtual, is still identical to the last program. Once again we are simply using pointers to each of the

objects, and in every case the pointer is of the same type as the object to which it points. You will begin to see some changes in the next example program, so be patient, we are almost there.

Once again, it would be best for you to compile and execute this program.

The four previous programs were meant to instruct you in what virtual functions do not do. The next two will show you what virtual functions do.