diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-8DF1C625-7963-55E9-BEEC-C9E37936F8CF.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-8DF1C625-7963-55E9-BEEC-C9E37936F8CF.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,35 @@ + + + + + +How +to use User::Leave()Provides a code snippet to explain how to use User::Leave(). +

You can use the User::Leave() function to terminate a +function’s processing immediately when an exception condition occurs. In the +example below, if the new fails, the function calls User::Leave() with +an error code. The return type of the function is void, because +it is not necessary to use it to return error information.

+void doExampleL() + { + CExample* myExample = new CExample; + if (!myExample) User::Leave(KErrNoMemory); + // leave used in place of return to indicate an error + + // do something + myExample->iInt = 5; + testConsole.Printf(_LIT("Value of iInt is %d.\n"),myExample->iInt); + // delete + delete myExample; + } +
Notes
    +
  • the L suffix +on a function name indicates that it may leave

  • +
+
\ No newline at end of file