Howdy, Stranger!

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

Categories

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

kishore1021kishore1021 Member Posts: 9
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

  • SteveCSteveC Member Posts: 63
    : 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
  • chamsterchamster Member Posts: 662
    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

  • Justin BibJustin Bib USAMember Posts: 0

    _________ [ http://forcoder.org ] free video tutorials and ebooks about [ C, C#, Visual Basic, Ruby, Java, Python, Go, PHP, PL/SQL, R, Delphi, Swift, MATLAB, JavaScript, Perl, Visual Basic .NET, Assembly, C++, Objective-C, Scratch Scheme, ML, Lisp, Clojure, Alice, Apex, Lua, Bash, D, F#, Hack, Rust, Kotlin, SAS, Scala, ABAP, FoxPro, Prolog, Fortran, Transact-SQL, VBScript, COBOL, Erlang, Awk, Crystal, Dart, Logo, LabVIEW, Ada, Julia ] ________

Sign In or Register to comment.