Symbian3/PDK/Source/GUID-1FC0156C-7BDB-5D5B-9860-837DAB431D24.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-1FC0156C-7BDB-5D5B-9860-837DAB431D24"><title>How to implement and use NewLC()</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>When an object is created through <codeph>NewLC()</codeph>, use <codeph>CleanupStack::PopAndDestroy()</codeph> to destroy the object when its use is complete.</p> <codeblock id="GUID-34A7790B-1FA9-58FA-83D9-A2CF6C07F2F2" xml:space="preserve">static CExample* CExample::NewLC()
       
    13     {
       
    14     CExample* self = new (ELeave) CExample();
       
    15     CleanupStack::PushL(self);
       
    16     self-&gt;ConstructL();
       
    17     return self;
       
    18     }</codeblock> <codeblock id="GUID-421A377A-7192-5908-A1C6-E3941046D489" xml:space="preserve">void doExampleL()
       
    19     {
       
    20     // allocate and push to cleanup stack - leave if failed
       
    21     CExample* myExample = CExample::NewLC();
       
    22     // do something that might leave
       
    23     myExample-&gt;DoSomethingL();  
       
    24     // pop from cleanup stack and destroy
       
    25     CleanupStack::PopAndDestroy(); 
       
    26     }</codeblock> </conbody></concept>