An array can be defined as an infinite collection of homogenous elements.An array
is a collection of similar data types.
Referencing(&) and dereferencing operator(*)operator
The & and * operators are used for referencing and dereferencing.The
ampersan(&) symbol is used in C++ to define reference type and as a bitwise
AND operator.We can use asterisk(*) as an operator to dereference a pointer and
as a multiplication operator.
The referencing operator is used to define referencing variable .A reference
variable prepares an alternate (alias) name of previously defined variable.The syntax of referencing operator is as follows Syntax: Data type & reference variable name=variable name; Example: int qty=20; int &qt=qty; qty is already declared and initialized.The second statement defines an alternative variable name, that is qt to variable qty; If both variables printed displays the same message.Any change made in one of the variable causes the change in both the variables. qt=qt*2; Now, contents of qt and qty will be 40. The declaration int & indicates the reference to the data type int. Principles for declaring reference variables 1) A reference variable should be initialized. 2) Once a reference variable is declared, it should not refer to any other variable. 3) The reference variable can be created referring to pointer variable.
The declaration is as follows char *s=”C++”; char *&q=s; 4) A variable can contain various references and modifying the value of one of them will result a change in all other variables. 5) Array of references is not allowed.