It would be interesting to comment the delete within the destructor, and see what happens:
Code:asset::~asset() { //delete [] name; }
It would be interesting to comment the delete within the destructor, and see what happens:
Code:asset::~asset() { //delete [] name; }
In principle, the compiler should hit an "Unexpected end of file" error. But anyway, that line should be fine, as should something like this:
By the way, what compiler are you using, misplaced?Code:#include <iostream> int main() { char* str = NULL; delete[] str; std::cout << "Deletion successful." << std::endl; return 0; }
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
>In principle, the compiler should hit an "Unexpected end of file" error.
Heh, let me try again:
There's a mystery here which would be nice to solve. I've run it with both Dev-C++ and Borland. Is it the compiler, or some part of the classes Misplaced hasn't posted?Code:asset::~asset() { //delete [] name; }
Well, misplaced, can you run it through a debugger? It sure would be nice to know exactly what line in what function call that the thing crashes on (one of the destructors I assume).
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
you solved the mystery.......Originally Posted by swoopy
delete [] name
was causing it all along.......
any ideas?
i seem to have GCC 3.3.4
But how do i start it?
I dont have a menu for it or anything.
Invalid pointer value AKA seg fault, or deconstructed twice (has happened to me). To make a solid deconstructor do this:
Code:asset::~asset(){ if(name) delete [] name; name=0; } //And had this to the asset constructor asset::asset() : name(0) /*other constructors*/{ // do the stuff you want }
Last edited by xErath; 11-20-2004 at 01:25 AM.
>any ideas?
A bug in your compiler?
Try these two things, and see if either or both work.
(1)
(2)Code:asset::~asset() { cout << "Asset ~asset()" << endl; if (name != NULL) delete [] name; }
Code:asset::~asset() { cout << "Asset ~asset()" << endl; delete name; }
Can you post the whole thing in a zip? I'd like to run it through a debugger.
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.