void func(int); // default
void func(int const); // same as default
void func(int) const; // error
void func2( int*); // default
void func2( int* const); // same as default
void func2( int const*); // overload
void func2( int const* const); // same as overload
struct foo {
void func3(int); // default
void func3(int const); // same as default
void func3(int) const; // overload, won't modify '*this'
void func3(int const) const; // same as overload
};
BTW: the same applies to 'volatile' or 'const volatile'.
Uli
`const' modifier is not "design-only" thing. It changes type
of the function. So, these functions are of different types:
struct X
{
void f();
void f() const;
};
If you call const function where non-const is expected, then
you will get compilation errors. I suggest you to read
following section of C++ FAQ:
"[18] Const correctness"
http://www.parashift.com/c++-faq-lite/const-correctness.html