@t3erminal  u r right!!!

thanks
surender
On Mon, Jul 4, 2011 at 4:16 PM, T3rminal <[email protected]> wrote:

> @himanshu: http://en.wikipedia.org/wiki/Virtual_inheritance
> Go through the last paragraph before reference.
>
> On Jul 4, 12:02 pm, himanshu kansal <[email protected]>
> wrote:
> > @piyush:what does this two virtual pointers storing???nd how does they
> help
> > in eliminating ambiguity....??
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 4, 2011 at 4:08 AM, T3rminal <[email protected]> wrote:
> > > @abc abc
> > > 4th class= two ints from X and Y classes + one int from base class( as
> > > this class is shared ) + 2 virtual pointers of X and Y classes.
> >
> > > On Jul 3, 2:24 pm, abc abc <[email protected]> wrote:
> > > > In the second case , the size of vptr will be added to each and every
> > > object
> > > > .
> > > > 1st class = one int :4
> > > > 2nd class = one int +one int from base + vptr =12
> > > > 3rd class = one int + one int from base + vptr =12
> > > > 4th class =one int from each base class + one int from each of the
> grand
> > > > parent +one vptr =20
> >
> > > > 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"...
> >
> > > > > --
> > > > > 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.
> >
> > > --
> > > 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.
> >
> > --
> >
> >       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.
>
>

-- 
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