p|OtrEk wrote:
What is practic difference between this two declarations?
If i want call my func with func("blah") i could write:
1) func(std::strin g const& arg1)
2) func(const std::string& arg1)
Whats better to use if i dont want to change content of arg1 it in func
body?
They're the same.
The types are read from right to left.
consider:
const int i; // i is a const int
int const i; // i is a const int
const int * i // i is a pointer to a const int.
int const * i // i is a pointer to a const int
int * const i // i is a const pointer to an int
const int * const i // i is a const pointer to a const int
int const * const i // i is a const pointer to a const int
References cannot be reseated (c.f., pointers), so they are already "const".
It's usually easier to read:
const int i;
yet, when stacking them up, it's usually easier the other way around:
int const * const
Ben
--
I'm not just a number. To many, I'm known as a String...