Home Forums C Programming Size of class

Viewing 0 reply threads
  • Author
    Posts
    • #2087
      valaraukar
      Participant

      Hi,
      Plz tell me the size of class D?
      If we inherite class A and B in class D then size of class D is 1 byte.
      but when we inherite class A,B and C then in class D then size of class D will be 2 byte.
      CODE……

      #include
      #include

      class A{
      };

      class B{
      };

      class C{
      };

      class D:public A, public B, public C{
      };

      int main()
      {
      A a;
      B b;
      C c;
      D d;

      cout << "Size of CLASS A " << sizeof(a) << endl;
      cout << "Size of CLASS B " << sizeof(b) << endl;
      cout << "Size of CLASS C " << sizeof(c) << endl;
      cout << "Size of CLASS D " << sizeof(d) << endl;

      getch();
      return 0;
      }

      Please solve my problem..

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.