0

Possible Duplicate:
What does const mean following a function/method signature?

Go ahead laugh at me, but what does the const after the function indicate?

int someFunc() const{  //<<----notice the const
    //insert code  blah...
}

If I wanted to a return type of const int wouldn't I just write

const int someFunc(){
    //code....
}
Community
  • 1
  • 1
vvMINOvv
  • 1,768
  • 4
  • 22
  • 45

3 Answers3

5

it means that the function can't alter any member variables.

class A {
void Func() const
{
  ++mI; // compiler error
}
int mI;
};
axon
  • 1,190
  • 6
  • 16
4

It means that that function wont change object properties, except 'mutable'

Alessandro Pezzato
  • 8,603
  • 5
  • 45
  • 63
  • thank's for the info, I feel @axon 's answer would be much easier to understand for noobs like myself :D . Thank's again – vvMINOvv Nov 23 '11 at 02:12
0

See this for much detailed definition. It's a very good one.

Adna Kateg
  • 93
  • 1
  • 6