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]
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]
Fill in your details below or click an icon to log in:
You are commenting using your WordPress.com account. ( Log Out / Change )
You are commenting using your Twitter account. ( Log Out / Change )
You are commenting using your Facebook account. ( Log Out / Change )
You are commenting using your Google+ account. ( Log Out / Change )
Connecting to %s
Notify me of new comments via email.
Notify me of new posts via email.