hi im using QT4.5 , Debian
Im having some doubts in QT memory management.
for ex:
class childClass
{
public :
int ival;
childClass();
};
childClass::childClass()
{
ival=5;
strval="test data";
lblstr->setText("label name");
}
class childClass
{
public :
QString strval;
int ival;
childClass();
QLabel *lblstr;
};
childClass::childClass()
{
ival=5;
strval="test data";
lblstr=new QLabel(this);
lblstr->setText("label name");
}
To copy to clipboard, switch view to plain text mode
im creating a object from another class named, mainClass
mainClass::createChild()
{
childClass *c=new childClass;
delete c;
qDebug<<c->ival;
qDebug<<c->strval;
}
mainClass::createChild()
{
childClass *c=new childClass;
delete c;
qDebug<<c->ival;
qDebug<<c->strval;
}
To copy to clipboard, switch view to plain text mode
Even after the delete command, qDebug able to print the ival,strval of childClass.
How to clear the variables ival,strval to free the memory?
Thnks
Bala
Bookmarks