virtual base classesthis ambiguity can be


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.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: virtual base classesthis ambiguity can be
Reference No:- TGS0309456

Expected delivery within 24 Hours