void func(const Class *myClass) { //...
As mentioned in other answers, this definition means that the parameter myClass
points to an instance of Class
that may not be modified (mutable
and const_cast
excepted) by the function. However the myClass
variable in the function body could be change to point at a different instance of Class
. This is an implementation detail of the function.
void func(Class *const myClass) { // ...
On the other hand this definition means that the myClass
parameter is a pointer to a Class
instance that is not const and hence can be used by the function to fully manipulate the class instance, but that the myClass
pointer variable itself cannot be altered to point at anything else in the function body.
One important point that hasn't been raised by other answers is that for function signatures, any top level const or volatile qualification is disregarded when considering the type of the function. This is because parameters are always passed by value, so whether they are const or not only affects whether the parameter itself can be changed in the body of the function and cannot affect the caller.
Thus these two function declarations are equivalent.
void func(Class *const myClass);
void func(Class *myClass);