I'm making my own string class, which I have just started, and I have typed up the following so far.
class My_String
{
char const* characters;
My_String(char const* _string);
void setString(const char const* _string);
};
In my My_String
method declaration, the argument has no const
at the beginning, whereas my setString
method declaration does.
(Note: I intend to have const
at the beginning of My_String
as well, however I don't in this example for comparison.)
I want a const
at the beginning of the argument because I don't intend to change _string
in the method.
However, Xcode gives me a warning (not error), underlining the second const
(adjacent to *
) of setString
, with a suggestion "Duplicate 'const' declaration specifier
", and offers to delete it for me.
Why does it do this? As far as I know, the 2 const
serve different purposes, and therefore are not redundant.