Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
different behavior of destructor
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ben Pope, post: 2550964"] [i][i] Beware, you have not created an operator=, although you are not using it here. Prefer: WithPointerMember wpm1(wpm); OK, this deallocated the internal string. Undefined behaviour. You cannot call member functions on destructed objects. The rest of the program is useless. What do you expect to happen now? wgm and wgm1 will be destructed, you cannot call the destructor of an object twice, it invokes undefined behaviour. Up to here is fine. You cannot reasonably expect anything after invoking undefined behaviour. wpm has been destructed, more undefined behaviour... Stop calling the destructor explicitly. Trust me, you'll never need to. What are you trying to achieve? Ben Pope[/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
different behavior of destructor
Top