how many constructors will be called when object of type D3 i will be created?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • braineater
    New Member
    • Apr 2010
    • 4

    #1

    how many constructors will be called when object of type D3 i will be created?

    Code:
    #include<iostream>
    using namespace std;
    
    class B
    {
      public:
          B();
    };
    class D1: public B
    {
      public:
         D1();
    };
    class D2 :public B
     {
       public:
          D2();
    };
    class D3: public D1, public D2
     {
      public:
         D3();
    };
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Can you make a guess?

    Comment

    • braineater
      New Member
      • Apr 2010
      • 4

      #3
      i think its 4 but m not sure

      i think its 4 but m not sure

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        Try adding debug print statements in the constructors, and then actually run the code.

        Comment

        Working...