C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table of virtual methods

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Milan Cermak
Guest





PostPosted: Mon Jun 28, 2004 7:46 pm    Post subject: Table of virtual methods Reply with quote



Hi all,
I have sort of philosophical question.
Contructor and destructor behavior points me to this.

Is table of virtual methods held in object?
Do I get it right that every created object has its own table of virtual
methods? Even if they are of one class?

Thanks for reactions,
Milan Cermak

Back to top
Howard
Guest





PostPosted: Mon Jun 28, 2004 8:22 pm    Post subject: Re: Table of virtual methods Reply with quote




"Milan Cermak" <nil (AT) nil (DOT) nil> wrote

Quote:
Hi all,
I have sort of philosophical question.
Contructor and destructor behavior points me to this.

Is table of virtual methods held in object?

There is no specificationin the standard as to how the addresses of virtual
methods are stored.

Quote:
Do I get it right that every created object has its own table of virtual
methods? Even if they are of one class?

No, that's not true. Whether they are virtual or not, the member functions
(and pointers to them in the case of virtual functions) only need to be
stored somewhere once per class (or struct) type. There's no need to copy
those for every object. That would be *very* wasteful.

Quote:

Thanks for reactions,
Milan Cermak




Back to top
John Harrison
Guest





PostPosted: Mon Jun 28, 2004 8:32 pm    Post subject: Re: Table of virtual methods Reply with quote




"Milan Cermak" <nil (AT) nil (DOT) nil> wrote

Quote:
Hi all,
I have sort of philosophical question.
Contructor and destructor behavior points me to this.

Is table of virtual methods held in object?
Do I get it right that every created object has its own table of virtual
methods? Even if they are of one class?


Typically each object holds a pointer to a table of virtual methods
(actually pointers to virtual methods). There is one table for each class,
and every object of the same class has the same pointer.

Multiple and virtual inheritance complicate this picture however.

If you are interested have a look at the book 'Inside the C++ Object Model'
by Stanley Lippman.

john



Back to top
EventHelix.com
Guest





PostPosted: Tue Jun 29, 2004 10:47 am    Post subject: Re: Table of virtual methods Reply with quote

The following articles will clear up some of these issues:

http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance.htm

http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance2.htm

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - Generate Sequence Diagrams in PDF (no drawing required)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.