HOW MANY INSTANCES OF THE VIRTUAL BASE CLASS WILL BE CRAETED IN last d

HOW MANY INSTANCES OF THE VIRTUAL BASE CLASS WILL BE CRAETED IN THE BOTTOM CLASS.

a is BASE CLASS class a
b and c are DERIVED CLASSES class b and class c
d is DERIVED DERIVED CLASS class d

class a
{
};
class b: public a
{
};
class c:public a
{
};

class d: public b ,public c
{
}
So How many Instances of class a are present in class d. Is there any way to change the number of Instances

Comments

  • : HOW MANY INSTANCES OF THE VIRTUAL BASE CLASS WILL BE CRAETED IN THE BOTTOM CLASS.
    :
    : a is BASE CLASS class a
    : b and c are DERIVED CLASSES class b and class c
    : d is DERIVED DERIVED CLASS class d
    :
    : class a
    : {
    : };
    : class b: public a
    : {
    : };
    : class c:public a
    : {
    : };
    :
    : class d: public b ,public c
    : {
    : }
    : So How many Instances of class a are present in class d.
    Count them - one of each, both contain 1 a - therefore 2 right?

    : Is there any way to change the number of Instances
    Rewrite the code?

    C++ is case sensitive
    And so are we - http://www.tuxedo.org/~esr/faqs/smart-questions.html#writewell
  • Will any instances get created? If i remember right ":"-symbol means that you inherit a class and extend it with your own stuff. But you don't create any instances by that. Am i totally confused?


    Kind Regards
    Konrad
    ----------------------------
    (+46/0) 708-70 73 92
    chamster@home.se
    http://konrads.webbsida.com

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories