473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with destructor

Hello. I have a big problem. I need your help!

I have a class whose only variable is a vector<char>.

I get messages like this:

*** glibc detected *** free(): invalid pointer: 0x089a6118 ***
Aborted.

I have looked up the error and it happens inside std::vector destructor.

My destructor is just ~MyClass() {};

What is happening?
Jul 23 '05 #1
6 1828
Nafai wrote:
Hello. I have a big problem. I need your help!

I have a class whose only variable is a vector<char>.

I get messages like this:

*** glibc detected *** free(): invalid pointer: 0x089a6118 ***
Aborted.

I have looked up the error and it happens inside std::vector destructor.

My destructor is just ~MyClass() {};

What is happening?


Could be it's during the destruction of a derived class object through
a pointer to the base class and the destructor is not virtual.

V
Jul 23 '05 #2
Victor Bazarov escribió:
Nafai wrote:
Hello. I have a big problem. I need your help!

I have a class whose only variable is a vector<char>.

I get messages like this:

*** glibc detected *** free(): invalid pointer: 0x089a6118 ***
Aborted.

I have looked up the error and it happens inside std::vector destructor.

My destructor is just ~MyClass() {};

What is happening?

Could be it's during the destruction of a derived class object through
a pointer to the base class and the destructor is not virtual.

V


There is no inheritance. I just have one class.
Jul 23 '05 #3
* Nafai:
Hello. I have a big problem. I need your help!

I have a class whose only variable is a vector<char>.

I get messages like this:

*** glibc detected *** free(): invalid pointer: 0x089a6118 ***
Aborted.

I have looked up the error and it happens inside std::vector destructor.

My destructor is just ~MyClass() {};

What is happening?


At line 542 the variable nGremlins is uninitialized.

Show the code.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #4
Nafai wrote:
[..]
There is no inheritance. I just have one class.


Then the answer is in the FAQ 5.8.

V
Jul 23 '05 #5
Victor Bazarov escribió:
Nafai wrote:
[..]
There is no inheritance. I just have one class.

Then the answer is in the FAQ 5.8.

V


Where can I find the FAQ? Thanks.
Jul 23 '05 #6
Nafai wrote:
Victor Bazarov escribió:
Nafai wrote:
[..]
There is no inheritance. I just have one class.


Then the answer is in the FAQ 5.8.

V

Where can I find the FAQ? Thanks.


The location of the FAQ is given in the Welcome message. If you don't
have this (or any of the past) week's Welcome messages on your server or
in your downloaded messages, here is the Web copy of it, please start
there: http://www.slack.net/~shiva/welcome.txt

You only need to read the Welcome message once. Please don't stop and
bail out of reading the Welcome message after you found the FAQ location.
It is important that you read it fully.

V
Jul 23 '05 #7

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

Similar topics

11
by: Andrew Skouloudis | last post by:
Hello people and merry christmas. I am trying to create a simple linked list and it seems i am doing something wrong with the DeleteNode function ... #include <malloc.h> #include <stdio.h>...
7
by: Emanuel Ziegler | last post by:
Hello, I want to do some mathematics with functions. In my case the function classes are very complex, but this simple example has the same problems. To allow calculations that begin with a...
1
by: Spur | last post by:
Hi all, I implemented a memory allocation/deallocation class that logs all new/delete calls (overloaded) and remembers for each allocated block where it was allocated from (using a macro that...
9
by: tonysuper | last post by:
Probably i have problem with co/des : if i call functions wich returns farray, programs go seg fault. if i comment destructor.. programs work but do not free memory. Any suggestion? ...
18
by: bArT | last post by:
Hi! I have a problem with such situation. I have a class like below and have some pointers (ptr1 and ptr2). I dynamically allocate memory in constructor and I free in destructor. For one pointer...
3
by: rahul8143 | last post by:
hello, I write a following program and have problem in understanding constructors and destructors. #include <iostream.h> class vector { public: double x; double y;
1
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip...
3
by: Juha Nieminen | last post by:
This is a simplified version of the situation (the actual situation is quite more complex, but when stripped to the bare minimum, it's like this): class BaseClass { public: virtual void...
8
by: lmfmaw | last post by:
Hi all, I've hit the wall with this "fairly" simple problem. As you can see in the code below, my destructors don't do their job as they are supposed to (I left them empty for this example). I'm...
3
by: GAURAV AGRAWAL | last post by:
Hi Guys, Can someone please explain me why this is happening #include<iostream> using namespace std; class a { public: int a1; // If I remove this it'll work fine
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...
0
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...

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.