C++ const member functions

Description

C++ const member functions

class aClass//  w  ww .  j  av a 2  s. 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;
}



PreviousNext

Related