|
-
November 23rd, 2009, 11:52 AM
#13
Re: static function to call member function on all objects?
What I was explaining was in the code you stuff default constructed objects into a vector.
First the default object gets created. At creation the this pointer is stored in the set. This 'this pointer' points to a temporary object.
Second this default constructed object is passed as a parameter to vector: ush_back which COPIES that object into the vector. Where does this copy come from? It comes from the copy constructor that because you neither provided one nor disallowed it, the compiler nicely generated for you. However that implicit copy constructor does not cause the set to be updated to reflect the new object in existence. Its why you get all those could not find pointer in set messages.
Whilst Paul is telling you never to write code that depends on destruction order that you cannot manage, I'm pointing out that you haven't even correctly kept a tab on 'live objects'.
Get Microsoft Visual C++ Express here or CodeBlocks here.
Get STLFilt here to radically improve error messages when using the STL.
Get these two can't live without C++ libraries, BOOST here and Loki here.
Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
Always use [code] code tags [/code] to make code legible and preserve indentation.
Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.
Tags for this Thread
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
|