473,586 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

issue deleting template class object

I have defined a template class (tree data structure) that uses dynamic
memory and has properly implemented ctor's, dtor and assignment
operator. I can observe the address of my tree object prior to the
destructor being called, and then the address once inside the
destructor...th ey're different! The following calls are on the stack
between the call to my destructor and the actual destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once inside
the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).

What exactly do the above methods do? BTW, I'm debugging with MS VC++
..NET.

Jan 9 '07 #1
2 2962
maynard wrote:
I have defined a template class (tree data structure) that uses
dynamic memory and has properly implemented ctor's, dtor and
assignment operator. I can observe the address of my tree object
prior to the destructor being called, and then the address once
inside the destructor...th ey're different! The following calls are
on the stack between the call to my destructor and the actual
destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once
inside the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).

What exactly do the above methods do? BTW, I'm debugging with MS VC++
.NET.
It might be best to ask in a VC++ newsgroup. Unless you feel like
following the recommendations of FAQ 5.8.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jan 9 '07 #2
maynard wrote:
I have defined a template class (tree data structure) that uses dynamic
memory and has properly implemented ctor's, dtor and assignment
operator. I can observe the address of my tree object prior to the
destructor being called, and then the address once inside the
destructor...th ey're different! The following calls are on the stack
between the call to my destructor and the actual destructor itself:

`eh vector destructor iterator'(void * ptr=0x00a6c454, ...)
`vector deleting destructor'()

I've also noticed that the address passed as "ptr" in the "eh vector
destructor iterator" is the address that my tree object has once inside
the destructor (again...it's not the same address prior to the
destructor being called). This is causing a run time exception (the
passed address points somewhere that isn't initialized to anything).
Are you slicing the object ?

Slicing refers to objects with a non-virtual destructor where you end up
deleting the wrong object. The same happens with copies.
Jan 9 '07 #3

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

Similar topics

8
3142
by: Tony Johansson | last post by:
Hello Experts! What does this mean actually. If you have a template with a type and non-type template argument, say, like this template<typename T, int a> class Array {. . .}; then A<int, 1> and A<int, 2> are different types. Now, if the A template
12
1568
by: Ken | last post by:
I am familiar with C and Java, I would like to use a style that I have become accustomed to in Java with C++ but each time I do this I have name conflict. In the past I have just worked around it by using different names can anyone tell me how to get the following to work: I want to have a class named v3d (vector 3d), it has the following...
4
14010
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
3
2470
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
8
1866
by: obrianpatrick | last post by:
Hi, I am relatively new to object oriented programming and design. I am developing an application in VS 2005. I am having the following design problem: I have two interfaces X and Y. Y is derived from X as the following: __interface X {
6
2338
by: bogus1one | last post by:
Hi All Given the following: // NamespaceTemplate.cpp : Defines the entry point for the console application. // #include "stdafx.h"
4
1847
by: Alexander Adam | last post by:
Hello folks, I got a few question on some basic data structure stuff. Sorry if those questions might sound too easy or such but after googling a lot I didn't find a real answer to all those questions so appreciate any help. I need to keep a very efficient data-tree structure (parent, previous, next, first child, last child) within the...
2
6182
by: Kai-Uwe Bux | last post by:
Does the following have undefined behavior? struct X; struct Y { X * x_ptr; Y ( void ) : x_ptr ( 0 )
6
5315
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. Here's a very simple example which should illustrate what I'm doing. #include <iostream> template <class T> class TestBase {
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7954
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...
0
8215
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...
1
5710
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...
0
5390
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...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.