Need example and explination...

This is a discussion on Need example and explination... within the C++ Programming forums, part of the General Programming Boards category; Hello people, I need an example and explination of the const keyword used in method signatures. I'm using a really, ...

  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,136
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21