Interview Question: Virtual Enhancement

Sample Question #129 (programming – C++)

What’s the difference between virtual and nonvirtual base classes?

[Source: exercise 14.6 in Prata, C++ Primer Plus, 5th edition]

This entry was posted in Sample Qs. Bookmark the permalink.

One Response to Interview Question: Virtual Enhancement

  1. Brett says:

    If two lines of inheritance for a class share a common nonvirtual ancestor, the class winds up having two copies of the ancestor’s members. Making the ancestor class a virtual base class solves this redundancy problem.
    [Adapted from Prata’s answer] 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s