|
-
March 26th, 2003, 02:46 PM
#1
thought I understood scope... guess not
I create items in a while loop:
MyStruct *temp = new MyStruct;
I add some data and then I put the items in a vector with much higher scope:
MyVector.push_back(*temp);
For a single varaible this works find but when I add the second variable the first varaible's destructor is called. I thought that if a variable is created as a pointer and new is used to allocate it, its destructor isn't call until I explicitly call delete or MyVector.clear().
What am I missing?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|