473,718 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

virtual destructor

Like other virtual functions does the entry of virtual destructor exist
in VTABLE?

Jan 5 '06 #1
8 3244
siddhu wrote:
Like other virtual functions does the entry of virtual destructor exist
in VTABLE?


In general, it's implementation dependent since there is no guarantee
that there is a vtable. Compilers can use other techniques to implement
virtual dispatching (though I don't know of any that do). See this FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-20.4

In any implementation that implements vtables, however, I'd guess yes,
it does.

Cheers! --M

Jan 5 '06 #2
siddhu wrote:
Like other virtual functions does the entry of virtual destructor exist
in VTABLE?


Yes, but only if the implementation actually has VTABLE. The Standard
does not require it, so it is not really a C++ language feature, it's
just an implementation detail.

V
Jan 5 '06 #3
On 5 Jan 2006 10:00:29 -0800, "mlimber" <ml*****@gmail. com> wrote:
siddhu wrote:
Like other virtual functions does the entry of virtual destructor exist
in VTABLE?


In general, it's implementation dependent since there is no guarantee
that there is a vtable. Compilers can use other techniques to implement
virtual dispatching (though I don't know of any that do). See this FAQ:


I'm curious: Please name one *current* C++ compiler that does not use
vtables. Just asking.

"Kites rise highest against the wind - not with it."
- Winston Churchill
Jan 5 '06 #4
He said: "(though I don't know of any that do)"

Jan 5 '06 #5
On 5 Jan 2006 11:45:19 -0800, gu*****@gmail.c om wrote:
He said: "(though I don't know of any that do)"


Hmm... let's think about that for awhile shall we. Yeah... just what I
thought.

From the Boost homepage:
"We aim to establish "existing practice" and provide reference
implementations so that Boost libraries are suitable for eventual
standardization . Ten Boost libraries are already included in the C++
Standards Committee's Library Technical Report ( TR1) as a step
toward becoming part of a future C++ Standard. More Boost libraries
are proposed for the upcoming TR2."

So many Boost features are NOT actually IN the C++ Standard.
Is that correct?

From V. Bazarov below:
"The Standard does not require it, so it is not really a C++ l
anguage feature, it's just an implementation detail."

Therefore, discussing Boost features NOT in the Standard is
forbidden in this ng, CORRECT?

I look forward to the Language Lawyers and Net Cops (notice I didn't
say engineers) expelling the horrendous offenders that populate this
ng. Thank you for defending us against the horde.

"All cats die. Socrates is dead. Therefore Socrates is a cat."
Jan 5 '06 #6
JustBoo wrote:
On 5 Jan 2006 11:45:19 -0800, gu*****@gmail.c om wrote:

He said: "(though I don't know of any that do)"

Hmm... let's think about that for awhile shall we. Yeah... just what I
thought.


OK, so you had your question answered before you asked it, right? What
are you going on for, then?
From the Boost homepage:
"We aim to establish "existing practice" and provide reference
implementations so that Boost libraries are suitable for eventual
standardization . Ten Boost libraries are already included in the C++
Standards Committee's Library Technical Report ( TR1) as a step
toward becoming part of a future C++ Standard. More Boost libraries
are proposed for the upcoming TR2."

So many Boost features are NOT actually IN the C++ Standard.
Is that correct?
Sure. That's why 'Boost' is called "a third-party library". And not all
of it is going to be part of future C++ library either.
From V. Bazarov below:
"The Standard does not require it, so it is not really a C++ l
anguage feature, it's just an implementation detail."

Therefore, discussing Boost features NOT in the Standard is
forbidden in this ng, CORRECT?
How do you arrive at that? Discuss implementation details as much as you
want, just remember that they are that, details, and are not guaranteed to
be in the next implementation you get to use. As soon as you decide to
rely on those features, you're bound to encounter more problems than if
you just use the Standard Library.
I look forward to the Language Lawyers and Net Cops (notice I didn't
say engineers) expelling the horrendous offenders that populate this
ng.
Really? This newsgroup is unmoderated. We do here as we please. Nobody
is expelled unless the ISP decides to pull the plug on the access to the
entire Internet. But those things are rare, and there are plenty of ISPs
out there who don't care.
Thank you for defending us against the horde.


I am guessing sarcasm here, but I just can't figure out what exactly in
this thread or in the poster's message to which you replied, warranted or
provoked that.

V
Jan 5 '06 #7
JustBoo wrote:
I'm curious: Please name one *current* C++ compiler that does not use
vtables. Just asking.


Actually, I think you would be hard pressed to find any *current* C++
compiler which implements virtual functions as calling a function from
some table like the original CFront compiler did: the CFront virtual
function table is the what I would consider a vtable. Modern C++
implementations typically use things called "thunks" which e.g. do
appropriate pointer adjustments before effectively calling into a
a function looked up by the thunk. The key difference here is that
you could simply call a function obtained from a vtable using the
'this' pointer in CFront's implementations . You cannot do anything
like this with the data looked up by a thunk because you would first
need to adjust the position the 'this' pointer points to.

That is, while you could in principle (if there were an accessible
member called '_Vtable' to access the virtual function table) use

(obj->_Vtable[idx])(obj)

to call a virtual function without arguments using a vtable, you
cannot do anything like this with thunks. Also note that there are
different approaches to thunks: these could be small functions which
are really generated or the necessary operations could be applied
inline.
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Jan 6 '06 #8
On Fri, 06 Jan 2006 14:50:52 +0100, Dietmar Kuehl
<di***********@ yahoo.com> wrote:
Actually, I think you would be hard pressed to find any *current* C++
compiler which implements virtual functions as calling a function from
some table like the original CFront compiler did: the CFront virtual
function table is the what I would consider a vtable. Modern C++
implementation s typically use things called "thunks" which e.g. do
appropriate pointer adjustments before effectively calling into a
a function looked up by the thunk. The key difference here is that
you could simply call a function obtained from a vtable using the
'this' pointer in CFront's implementations . You cannot do anything
like this with the data looked up by a thunk because you would first
need to adjust the position the 'this' pointer points to.
Wow, what goes around comes around. I remember thunking functions
in the good ol' bad ol' days of Win16 - that's Win16 - programming.
IIRC it involved FAR (sorta' 32bit) segment/offset addressing. You had
a pre and post operation for each function. Much as you describe
above.
That is, while you could in principle (if there were an accessible
member called '_Vtable' to access the virtual function table) use

(obj->_Vtable[idx])(obj)

to call a virtual function without arguments using a vtable, you
cannot do anything like this with thunks. Also note that there are
different approaches to thunks: these could be small functions which
are really generated or the necessary operations could be applied
inline.


I'm a bit surprised, I won't mention the specific compiler -
unfortunately the most popular one on earth - again if IIRC - allows
straight C programs to develop a direct pointer into a certain
subsystem vtable and access it without thunking. They call it "VTBL
Binding." Of course this compiler is not known for standard behavior.

You did say any current compiler. :-) Does gcc not allow access to
it's vtables?

I have learned something, I like that.
Jan 6 '06 #9

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

Similar topics

11
10519
by: Stub | last post by:
Please answer my questions below - thanks! 1. Why "Derived constructor" is called but "Derived destructor" not in Case 1 since object B is new'ed from Derived class? 2. Why "Derived destructor" is called in Case 2 since only ~base() becomes "virtual" and ~Derived() is still non-virtual? 3. Does Case 3 show that we don't need any virtual destructor to make ~Derived() called? 4. Is "virtual destructor" needed only for Case 2?
7
1888
by: qazmlp | last post by:
When a member function is declared as virtual in the base class, the derived class versions of it are always treated as virtual. I am just wondering, why the same concept was not used for the destructors. What I am expecting is, if the destructor is declared as virtual in base, the destructors of all its derived classes also should be virtual always. What exactly is the reason for not having it so?
23
2148
by: heted7 | last post by:
Hi, Most of the books on C++ say something like this: "A virtual destructor should be defined if the class contains at least one virtual member function." My question is: why is it only for the case when the class contains at least one virtual member function? Shouldn't the destructor always be virtual, whenever there's a possibility that an inherited object will be destructed through a base class pointer? (This does not require,
37
4169
by: WittyGuy | last post by:
Hi, I wonder the necessity of constructor and destructor in a Abstract Class? Is it really needed? ? Wg http://www.gotw.ca/resources/clcm.htm for info about ]
4
8433
by: Tony Johansson | last post by:
Hello Experts!! Assume I have a base class called animal. I want this class to be abstract so I make the destructor pure virtual by having this statement. virtual ~Animal() = 0; Destructor will never be inherited. Now to my question why do I have to give a body {} at least the empty body to the pure virtual destructor.
26
3975
by: pmizzi | last post by:
When i compile my program with the -ansi -Wall -pedantic flags, i get this warning: `class vechile' has virtual functions but non-virtual destructor, and the same with my sub-classes. But when i add a virtual destructor like this : " virtual ~vechile". I get this error: Undefined first referenced symbol in file vtable for vechile /var/tmp//ccC9yD6Z.o
5
11359
by: druberego | last post by:
I read google and tried to find the solution myself. YES I do know that you can get undefined references if you: a) forget to implement the code for a prototype/header file item, or b) you forget to pass all the necessary object files to the linker. Neither of those are my problem. Please bear with me as the question I ask is rather long and I think it's beyond a CS101 level of linker stupidity. If it is a stupid CS101 mistake I'm making...
7
3086
by: eric | last post by:
hello i'm confused by an example in the book "Effective C++ Third Edition" and would be grateful for some help. here's the code: class Person { public: Person(); virtual ~Person(); // see item 7 for why this is virtual ...
7
2005
by: sam | last post by:
Hi, See when i reading a sourcecode of a program, I read that the constructor is ordinary and after that the programmer has written virtual destructor for that constructor . Why we use the virtual destructor whats the use of it? the code is like this: Network(int input,int output); Network(&Network); virtual ~Network();
17
3539
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;" instead? I think declaring a function as "=0" is the same
0
8724
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9208
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9121
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9053
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6654
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5971
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4481
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3182
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 we have to send another system
2
2559
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.