| View previous topic :: View next topic |
| Author |
Message |
Milan Cermak Guest
|
Posted: Mon Jun 28, 2004 7:46 pm Post subject: Table of virtual methods |
|
|
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
|
Posted: Mon Jun 28, 2004 8:22 pm Post subject: Re: Table of virtual methods |
|
|
"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
|
Posted: Mon Jun 28, 2004 8:32 pm Post subject: Re: Table of virtual methods |
|
|
"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
|
|
| Back to top |
|
 |
|