I'm quite new to Qt and am wondering on some basic stuff with memory management and the life of objects. When do I need to delete / destroy my objects? Is any of this handled automatically?
In the example below, which of the objects I create do I need to delete? What happens to the instance variable myOtherClass when myClass is destroyed? What happens if I don't delete / destroy my objects at all, will that be a problem to memory?
in MyClass.h:
class MyClass
{
public:
MyClass();
~MyClass();
MyOtherClass *myOtherClass;
};
in MyClass.cpp:
MyClass::MyClass() {
myOtherClass = new MyOtherClass();
MyOtherClass myOtherClass2;
QString myString = "Hello";
}
As you can see this is quite newbie-easy stuff but where can I learn about this in an easy way?
Thanks really much