diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-1FC0156C-7BDB-5D5B-9860-837DAB431D24.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-1FC0156C-7BDB-5D5B-9860-837DAB431D24.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,26 @@ + + + + + +How to implement and use 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(); + }
\ No newline at end of file