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

Explain register variable, Explain Register Variable Computers have int...

Explain Register Variable Computers have internal registers, which are used to keep data temporarily, before any operation can be performed. Intermediate results of the calcula

Luminous Jewels - The Polishing Game, Byteland county is very famous for lu...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Main program to test the basic operations, The Main program is slightly mor...

The Main program is slightly more complicated and you need to think about the I/O process. First of all, for most applications you do not call the low level routines GetChar and P

When is a template a better solution than a base class, When you are design...

When you are designing a generic class to have or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or

Arithmetic operation, a program that declares and prompts the user to enter...

a program that declares and prompts the user to enter two integer and performs the five arithmetic operations

Stack, Implement multiple stacks in a single dimensional array. Write algor...

Implement multiple stacks in a single dimensional array. Write algorithms for various stack operations for them.

Program, write a c++ program which finds minimum of three numbers

write a c++ program which finds minimum of three numbers

Program to create a class and store student information, Develop a Student ...

Develop a Student class that has the following header file: #ifndef STUDENT_H #define STUDENT_H #include #include #include using namespace std; class Stu

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