Demonstrate const member functions - C++ Class

C++ examples for Class:Member Function

Description

Demonstrate const member functions

Demo Code

class aClass//  w w w .j av a 2s  .c o  m
{
   private:
   int alpha;
   public:
   void nonFunc()        //non-const member function
   { alpha = 99; }    //OK
   //      void conFunc() const  //const member function
   //       { alpha = 99; }    //error: can't modify a member
};
int main()
{
   return 0;
}

Related Tutorials