Board index » cppbuilder » Re: How does this code behave?
Chris Uzdavinis
![]() CBuilder Developer |
Chris Uzdavinis
![]() CBuilder Developer |
Re: How does this code behave?2007-10-09 03:13:21 AM cppbuilder108 "Hendrik Schober" < XXXX@XXXXX.COM >writes: QuoteI have no idea what your "VP" refers to. -- Chris (TeamB); |
Alex Bakaev [TeamB]
![]() CBuilder Developer |
2007-10-09 04:58:43 AM
Re:Re: How does this code behave?
Alex Bakaev [TeamB] wrote:
QuoteAnd that's what (at least on the surface) seems strange. If I'm not contributed the feature t Net 2.0 :) |
Old Wolf
![]() CBuilder Developer |
2007-10-09 12:46:55 PM
Re:Re: How does this code behave?
"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote:
QuoteI'm not sure I understand how this code should behave: the Base1 function as well as the Base2 function. In fact I'm told there's an example of this in TC++PL. If you want to only override the Base1 function, you have to introduce an intermediate class between Base2 and Derived. {smallsort} |
Old Wolf
![]() CBuilder Developer |
2007-10-09 12:48:06 PM
Re:Re: How does this code behave?
"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >wrote:
QuoteI'm not sure I understand how this code should behave: the Base1 function as well as the Base2 function. In fact I'm told there's an example of this in TC++PL. If you want to only override one of the functions, you have to introduce an intermediate class. |
Vladimir Grigoriev
![]() CBuilder Developer |
2007-10-09 07:17:56 PM
Re:Re: How does this code behave?
Sorry but tabs were ignored when I pasted the code.
VP is vtbl-pointer.:) I tried to say that then an object of a derived class is created it has the same number of pointers to vtbls as the number of abstract base classes from which it was derived. So if a class c4 is derived from three abstract classes c1, c2, c3 then its sizeof( c4 ) (it has not any data member only one virtual function) will be equal to size of a pointer multiplyed by number of abstract classes. Vladimir Grigoriev "Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote"Hendrik Schober" < XXXX@XXXXX.COM >writes: |
Vladimir Grigoriev
![]() CBuilder Developer |
2007-10-09 08:22:51 PM
Re:Re: How does this code behave?
In your example classes A and B is not abstract classes.
Vladimir Grigoriev "Hendrik Schober" < XXXX@XXXXX.COM >wrote in message QuoteVladimir Grigoriev < XXXX@XXXXX.COM >wrote: |
Alan Bellingham
![]() CBuilder Developer |
2007-10-09 09:03:49 PM
Re:Re: How does this code behave?
"Vladimir Grigoriev" < XXXX@XXXXX.COM >wrote:
QuoteI tried to say that then an object of a derived class is created it has the (It *can* have multiple pointers, it only *needs* one. Table layouts with multiple base classes gets complicated, and casting can then involve pointer arithmetic.) Alan Bellingham -- Team Browns ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK |
Alan Bellingham
![]() CBuilder Developer |
2007-10-09 09:34:11 PM
Re:Re: How does this code behave?
Alan Bellingham < XXXX@XXXXX.COM >wrote:
QuoteAh, now that's where you were wrong, you see. It only needs a pointer to Alan Bellingham -- Team Browns ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK |
Vladimir Grigoriev
![]() CBuilder Developer |
2007-10-09 10:02:18 PM
Re:Re: How does this code behave?
The results show ( VC++ 2005 EE) that if a class (with only one virtual
function and nothing more) is derived from four abstract classes then its sizeof == 16. If a class is derived from three abstract classes then its sizeof == 12, and so on. Vladimir Grigoriev "Alan Bellingham" < XXXX@XXXXX.COM >wrote in message QuoteAlan Bellingham < XXXX@XXXXX.COM >wrote: |
Alan Bellingham
![]() CBuilder Developer |
2007-10-09 11:42:56 PM
Re:Re: How does this code behave?
"Vladimir Grigoriev" < XXXX@XXXXX.COM >wrote:
QuoteIn your example classes A and B is not abstract classes. Quote>struct A { Alan Bellingham -- Team Browns ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK |
Duane Hebert
![]() CBuilder Developer |
2007-10-10 12:03:53 AM
Re:Re: How does this code behave?
"Alan Bellingham" < XXXX@XXXXX.COM >wrote in message
Quote"Vladimir Grigoriev" < XXXX@XXXXX.COM >wrote: And, as such, cannot be instantiated. Neither of these is pure virtual. |
Duane Hebert
![]() CBuilder Developer |
2007-10-10 12:08:12 AM
Re:Re: How does this code behave?
"Duane Hebert" < XXXX@XXXXX.COM >wrote in message
Quote
|
Alex Bakaev [TeamB]
![]() CBuilder Developer |
2007-10-10 12:19:25 AM
Re:Re: How does this code behave?
Old Wolf wrote:
Quote
|
Alan Bellingham
![]() CBuilder Developer |
2007-10-10 12:20:02 AM
Re:Re: How does this code behave?
"Duane Hebert" < XXXX@XXXXX.COM >wrote:
QuoteThis may be a matter of semantics but AFAIK an abstract class (And coping with top-posted originals is not my excuse.) What I should have been worrying about was that they were both *polymorphic* classes. Whether they also happen to be abstract or not is rather irrelevant to vtable layout, since the effect of pure virtual functions is to prevent instantiation of the class in which they exist, not to change inheritance. Alan Bellingham -- Team Browns ACCU Conference 2008: 2-5 April 2008 - Oxford (probably), UK |
Duane Hebert
![]() CBuilder Developer |
2007-10-10 12:34:48 AM
Re:Re: How does this code behave?
"Alan Bellingham" < XXXX@XXXXX.COM >wrote in message
Quote"Duane Hebert" < XXXX@XXXXX.COM >wrote: Quote(And coping with top-posted originals is not my excuse.) QuoteWhat I should have been worrying about was that they were both by name) and how the derived class handled it. I'm not sure what the example without abstract base classes was getting at. |