1 MORE QUES....HOW IS "DELEGATED TO SISTER CLASS" IMPLEMENTED...MEANS HOW
CAN ONE CLASS CALL ANOTHER CLASS'S FUNCTION WITHOUT KNOWING ANYTHING ABOUT
IT....
On Sun, Jul 3, 2011 at 2:43 PM, himanshu kansal <[email protected]
> wrote:

> class Base
> {
>      public:
>            int a;
> };
>
> class X:  public Base
> {
>      public:
>            int x;
> };
>
> class Y:  public Base
> {
>      public:
>            int y;
> };
>
> class Z:public X,public Y
> {
> };
>
> int main()
> {cout<<sizeof(Base)<<endl;
> cout << sizeof(X) <<endl;
> cout << sizeof(Y) <<endl;
> cout << sizeof(Z) <<endl;
> }
> o/p is 4
> 8
> 8
> 16...
> which is absolutely fine.....
>
> but the problem arises here....
> class Base
> {
>      public:
>            int a;
> };
>
> class X:virtual public Base
> {
>      public:
>            int x;
> };
>
> class Y:virtual public Base
> {
>      public:
>            int y;
> };
>
> class Z:public X,public Y
> {
> };
>
> int main()
> {cout<<sizeof(Base)<<endl;
> cout << sizeof(X) <<endl;
> cout << sizeof(Y) <<endl;
> cout << sizeof(Z) <<endl;
> }
>
> o/p is 4
> 12
> 12
> 20
> why the size is 12 and 20 for x and Z....does this is because that
> some sort of VPTR IS maintained in the class....if yes then then what
> does that points to....
>
> PS:HERE.....i am talking about virtual inheritance....NOT ABOUT
> "VIRTUAL FUNCTIONS"...
>



-- 

      Regards
Himanshu Kansal
  Msc Comp. sc.
(University of Delhi)

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to