What would you do?

Hello guys,
My programming professor is insisting that we use the keyword const when declaring our function of a class for example:

1
2
3
//in class header file
bool space_in_front(int) const;
bool space_in_front(const int);


I realize that when it follows the parameter list it prevents the object from being modified and when it's in the parameter list it prevents any of the variables from being modified. My question is, is it wrong to write them as
bool space_in_front(const int) const; where const appears in both, or is this somehow redundant.
Thanks for any feedback you may have.
Last edited on
They're not the same thing.

This allows a const instance of your object to call space_in_front.
 
bool space_in_front(int) const;


These, in practice, is are the same. The const gives you nothing:
1
2
bool space_in_front(const int);
bool space_in_front(int);
Last edited on
Topic archived. No new replies allowed.