473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 22 '05 #1
3 1620

"Milan Cermak" <ni*@nil.nil> wrote in message
news:9A*******************@news.chello.at...
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.
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.

Thanks for reactions,
Milan Cermak

Jul 22 '05 #2

"Milan Cermak" <ni*@nil.nil> wrote in message
news:9A*******************@news.chello.at...
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
Jul 22 '05 #3
The following articles will clear up some of these issues:

http://www.eventhelix.com/RealtimeMa...erformance.htm

http://www.eventhelix.com/RealtimeMa...rformance2.htm

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - Generate Sequence Diagrams in PDF (no drawing required)
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
1738
by: Raymond Lewallen | last post by:
I read this on this website page http://www.vbip.com/books/1861004915/chapter_4915_06.asp: Unlike many object-oriented languages, all methods in VB.NET are virtual. Now in BOL, Under...
32
4469
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
14
12107
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using...
175
8649
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
5
15838
by: ^MisterJingo^ | last post by:
Is it good pratice to make base class properties virtual? For example: public abstract class Person { protected string name; public virtual string Name { //get, set stuff here } }
1
2534
by: Ryan Kaskel | last post by:
Hi! I am new to this newsgroup and need help implementing a hash table. This assignment is for school but only concerns one method. Basically we have to write methods like put(), get(),...
3
4533
by: kikazaru | last post by:
Is it possible to return covariant types for virtual methods inherited from a base class using virtual inheritance? I've constructed an example below, which has the following structure: Shape...
318
10745
by: King Raz | last post by:
The shootout site has benchmarks comparing different languages. It includes C# Mono vs Java but not C# .NET vs Java. So I went through all the benchmark on the site ... ...
4
1613
by: harsh.murari | last post by:
In the example below, a single object (Network) is implementing 2 interfaces (INetworkA and INetworkB). Both of these interfaces derive from the IBase interface (similar to the IUnknown interface...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.