I have come across a program in which there is a class with name "A".
There is the following syntax in the declaration of a variable that I am not able to understand.
A& obj;
what does this mean and in what cases this is used.
I have come across a program in which there is a class with name "A".
There is the following syntax in the declaration of a variable that I am not able to understand.
A& obj;
what does this mean and in what cases this is used.
obj
is a reference
to an A
object. Presumably this is a class data member, since references cannot be default initialized (they have to refer to something from the outset).
struct Foo
{
int& a;
Foo(int n) : a(n) {} // must be initialized in constructor initialization list.
}