Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where ampersand "&" can be put when passing argument by reference?

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.

like image 530
Roman Avatar asked Mar 13 '13 16:03

Roman


People also ask

Where do we use ampersand?

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.

Where does ampersand come from?

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 this symbol called &?

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.

Why is ampersand not a letter anymore?

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.)


1 Answers

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!

like image 180
Nawaz Avatar answered Sep 19 '22 13:09

Nawaz