diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-1D9376CD-3160-5CD8-A138-B94C5F7A50F8.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-1D9376CD-3160-5CD8-A138-B94C5F7A50F8.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,35 @@ + + + + + +Using +MUTABLE_CAST macroThis topic explains how to cast away the constant of the counter +variable. +

In the example code below, the class has a simple const getter function Var(). +It uses MUTABLE_CAST to cast away the const -ness +of the counter variable iGetCounter, which allows that variable +to be changed.

+class TMutableDemo + { +public: + TMutableDemo(TUint a=0):iVar(a),iGetCounter(0) {}; + TUint Var() const; + +private: + TUint iVar; + __MUTABLE TUint iGetCounter; + }; + +TUint TMutableDemo::Var() const + { + MUTABLE_CAST(TMutableDemo*,this)->iGetCounter++; + return iVar; + } +
\ No newline at end of file