LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-26-2009, 12:29 PM   #1
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
wxwidgets dynamic classes


I'm trying to learn this tutorial:
http://www.zetcode.com/tutorials/wxw...firstprograms/

How come he never has to use delete after calling new? Shouldn't he add a destructor to the class?
 
Old 11-26-2009, 01:28 PM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
well,
all process memory is reclaimed on exit, so for a simple fire and forget app
it's not such a big worry.

you could delete but as the prog is about to die anyway it's a waste of keystrokes!


remember tutorials generally get you up and running with
minimal checks and safety devices.
otherwise the examples get too long.

Last edited by bigearsbilly; 11-26-2009 at 01:29 PM.
 
Old 11-26-2009, 01:56 PM   #3
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Original Poster
Rep: Reputation: 34
Okay. So in a bigger app where those dynamic things go out of scope, it would be important to free them. Just checking.
 
Old 11-26-2009, 03:31 PM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
yes, for a long running daemon that stays on all the time it would be vital.
 
Old 11-27-2009, 05:39 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
well, there are also things called smart pointers

google:std::tr1::shared_ptr
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
WxWidgets icecubeflower Linux - Newbie 2 11-24-2009 10:44 AM
[C++] Classes and dynamic memory Ephracis Programming 17 12-30-2006 01:55 AM
wxWidgets kornerr Programming 2 10-13-2005 10:05 AM
OOP (PHP) classes and extended classes ldp Programming 3 03-05-2005 11:45 AM
C++ dynamic classes tristan_vdv Programming 1 01-04-2002 04:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration