I am using pass by reference to const string in a function argument like below:
class Super
{
void alignment(const string & str);
};
void Super::alignment(const string & str)
{
//do some stuff
}
Now if I use as below it gives the same result:
void Super::alignment(string const & str)
{
//do some stuff
}
What is the difference in this two types of definition in c++?
const T&
and T const&
are semantically the same exact thing. Just like const T*
and T const*
are semantically the same, but T const*
and T* const
are different.