Thread: Need example and explination...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    30

    Exclamation Need example and explination...

    Hello people, I need an example and explination of the const keyword used in method signatures. I'm using a really, crappy book and i don't understand what they are trying to say. Thanks!
    Last edited by Gamma; 04-15-2002 at 09:36 PM.

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    It means it does not change values.

    Code:
    class foo
    {public:
         int returnint() const;//doesn't change the value of it
         void setint(int number);
    
      private:
          int data=0;
    }
    
    int returnint() const
    { return data;}
    
    void setint(int number)
    { data=number}
    That's just something quick I threw together to show you. There might be some syntax errors.

Popular pages Recent additions subscribe to a feed