Q:

C++ const function with reference

In this function :
(Counter is the class in which the function operator++ is declared)
const Counter& operator++ ();

What means the const for my function ? I don't really understand the const keyword in combination with pointers or references !

A:

It means that you may not use this reference to change the object it referes to. For example if you have two objects of type Counter
Counter obj1, obj2;

then you may not write
++obj1 = obj2;

because due to the qualifier const the object refered to by the reference returned by operator ++ is immutable.
If you would remove the const qualifier in the operator declaration then this statement
++obj1 = obj2;

would be valid.
In fact it is not a good idea to declare the preincrement operator returning const reference. Usually it declared  without the const qualifier
Counter& opperator++ ();

In this case it behaves the same way as the preincrement operator ++ for arithmetic tyoes. For example this code is valid
int x = 1;
++x = 2;
and the result is x = 2;

