Could anyone please explain all the different types of ways to pass by parameters? Specifically, involving ampersands ('&') and the 'const' keyword. I've seen many kinds, but I don't really understand what they do, and when they should be used.
To list a few: Type & const Type const & const Type &
Also, I'm not sure what syntax to use. For example, for a parameter of type int & const
called a
, is it written as int & a const
or int & const a
? For an int const &
parameter called a
, is it written int const & a
or int const a &
?
Here is what I understand. I understand how to create a reference. I know that a reference is like an alias to an address, and does not make a copy of the parameter. I also get that the ampersand symbol can sometimes mean addresses.
If anyone could clarify this, I would really appreciate it.