If I instantiate class objects inside ofApp.cpp, using the new operator - which allocates them in heap memory - , where do I need to delete them, if they remain valid until the application is closed?
Is there for instance something like an ofApp::exit() method that executes code right before quitting the application?
Or should I declare and define a destructor for the ofApp class, and if so, does it take care of the cleanup at the end, if I put delete myObject inside its definition?
heyho,
there is an exit function you can override.
should be also fine to add a destructor. i am not an expert c++ programmer, but i always try to avoid pointers. if i have to, then i try to use smart pointers. there is a chapter in the ofBook about smart pointers. https://openframeworks.cc/ofBook/chapters/memory.html#smartpointers
hope that helps