- This topic has 0 replies, 1 voice, and was last updated 16 years, 9 months ago by .
Viewing 0 reply threads
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.
Home › Forums › C Programming › Size of class
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……
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include<iostream.h><br /> #include<conio.h><br /> <br /> class A{<br /> };<br /> <br /> class B{<br /> };<br /> <br /> class C{<br /> };<br /> <br /> class D:public A, public B, public C{<br /> };<br /> <br /> int main()<br /> {<br /> A a;<br /> B b;<br /> C c;<br /> D d;<br /> <br /> cout << "Size of CLASS A " << sizeof(a) << endl;<br /> cout << "Size of CLASS B " << sizeof(b) << endl;<br /> cout << "Size of CLASS C " << sizeof(c) << endl;<br /> cout << "Size of CLASS D " << sizeof(d) << endl;<br /> <br /> getch();<br /> return 0;<br /> } |
Please solve my problem..