In the examples that I saw the arguments were passed by reference in the following way:
void AddOne(int &y)
In the code that I have I see the following syntax:
void AddOne(int& y)
I wonder if it is the same or the second case is somehow different from the first one.
An ampersand (&) is a typographical symbol that is rarely used in formal writing. It is read aloud as the word and and is used as a substitute for that word in informal writing and in the names of products or businesses.
The symbol & comes from the first century AD, when scribes wrote in Latin cursive. The ampersand symbol actually comes from the Latin word et, which means and. Linking the letters e and t created the ampersand symbol. Today, the ampersand symbol still signifies the word and.
What is an &? & is called an ampersand symbol (pronounced “AM- per-sand”). Essentially, it means “and”. It is used both (a) in the body of the paper as part of a citation and (b) at the end of the paper as part of a reference.
Over time, “and per se and” was slurred together into the word we use today: ampersand. When a word comes about from a mistaken pronunciation, it's called a mondegreen. (If you sing the wrong lyrics to a song, that's also known as a mondegreen.)
Both are exactly the same. No difference at all.
All that matters is that &
should be between the type and the variable name. Spaces don't matter.
So
void AddOne(int& y);
void AddOne(int &y);
void AddOne(int & y)
void AddOne(int & y);
void AddOne(int&y);
are same!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With