Explain virtual base classes, C/C++ Programming

Assignment Help:

Virtual Base Classes

This ambiguity can be resolved if the class derived have only one copy of the class base. This can be done by making the base class a virtual class. This keyword makes the two classes share a one copy of their base class . It can be done as follows :

                class base

                 {

                                :

                                :

                 };

class  Aclass : virtual public base

                 {

                                :

                                :

                 };

 

                class  Bclass : virtual public base

                 {

                                :

                                :

                 };

 

                class  derived : public Aclass, public Bclass

                 {

                                :

                                :

                 };

This will resolve the ambiguity included.

 


Related Discussions:- Explain virtual base classes

Pointer to an array, Write a method (belonging to the TermStructure class) ...

Write a method (belonging to the TermStructure class) that takes a pointer to an array of bonds and an integer, representing the number of bonds in the array as arguments, and esti

How private instance of a class can be assigned values, Question 1: (a)...

Question 1: (a) Explain clearly the following concepts using suitable examples of your own:- (i) concrete class v/s abstract class (ii) constructor v/s over

Skilled programmer is required to build a standalone module, A skilled prog...

A skilled programmer is required to build a standalone module to extract, parse and store in database tables, word count data from web pages and RSS feeds. The module can take R

#title prime number or not, to find prime numbers upto any number say "n" e...

to find prime numbers upto any number say "n" entered by user

Define the self-referential structures, Define the Self-Referential Structu...

Define the Self-Referential Structures? It is occasionally desirable to include within a structure one member that is a pointer to the parent structure type. Generally in terms

Template class and class template in c++, Differentiate between a template ...

Differentiate between a template class and class template in C++? Ans) Template class: A generic definition or a parameterized class not instantiated until the client gives the

How to use turbo c, Sir i want to know all the basic knowledge of turbo c.

Sir i want to know all the basic knowledge of turbo c.

Where are longjmp and setjmp used in c++, Where are longjmp and setjmp used...

Where are longjmp and setjmp used in C++? -Setjmp and longjmp must not be used in C++. - Longjmp jumps out of the function without unwinding stack. This means that local obj

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd