This document describes how to destroy objects created with NewLC() .
When an object is created through NewLC() , use CleanupStack::PopAndDestroy() to destroy the object when its use is complete.
static CExample* CExample::NewLC()
{
CExample* self = new (ELeave) CExample();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
void doExampleL()
{
// allocate and push to cleanup stack - leave if failed
CExample* myExample = CExample::NewLC();
// do something that might leave
myExample->DoSomethingL();
// pop from cleanup stack and destroy
CleanupStack::PopAndDestroy();
}
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.