Thread: new without delete => bad ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by drrngrvy
    aren't there any delete-like operators that will work on both free-store and non free-store variables? It would make things cleaner if there was one.
    why would you need to delete non-heap variables?

    Manual memory management is, in general, a receipe for disaster. Good coding practice in C++ is to use the RAII idiom. Specifically have a look at the standard library auto_ptr and (even more useful) the boost shared_ptr classes.

    Hope that helps
    Last edited by ChaosEngine; 10-13-2005 at 07:24 PM. Reason: yeah... what daved said!
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  2. MSVC 2003 Debugging delete
    By Bajanine in forum Windows Programming
    Replies: 2
    Last Post: 09-09-2007, 12:15 PM
  3. Proper Usage of the delete Operator
    By thetinman in forum C++ Programming
    Replies: 7
    Last Post: 04-25-2007, 11:53 PM
  4. delete by copy only for non-children nodes?
    By patricio2626 in forum C++ Programming
    Replies: 17
    Last Post: 11-18-2006, 08:37 AM
  5. Shocking(kind of)
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 12-10-2002, 08:52 PM