Hi guys,
If am cretating a QObject 's object in a stack , will it call the distructor after the "AUTO" scope..
see the below code...
{
public :
{
cout<<"\n MyClass() ...";
}
~ MyClass()
{
cout<<__FUNCTION__ ;
}
private:
};
int main( int argc, char *argv[] )
{
MyClass obj
qDebug()<<"Hello Qt 4.2.2 ";
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
class MyClass : QObject
{
public :
MyClass( const QString & name )
:_name( name ),QObject( )
{
cout<<"\n MyClass() ...";
}
~ MyClass()
{
cout<<__FUNCTION__ ;
}
private:
QString _name;
};
int main( int argc, char *argv[] )
{
QApplication a(argc, argv);
MyClass obj
qDebug()<<"Hello Qt 4.2.2 ";
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
In this code ( obj in stack ) , ~MyClass() is not getting called.
But if i am creating the "obj " in heap and "delete obj" will call the ~MyClass..
Could you please tell me why this distructor is not getting called while object is created in stack...???
Bookmarks