Breaking News

What is the Pointers In C++ or any Programming Language?

A pointer is a variable that holds a memory address. This address is usually the location the location of another variable in memory.

If one variable contains the address of another variable, is said to point to the second.

References

A reference is an alternative name for an object. A reference variable provides an alias for a previously defined variable.

C++ introduces a new data type called reference. You can think of them as if they were “aliases” to “real” variables or objects.

As an alias cannot exist without its corresponding real part, you cannot define single references. The ampersand (&) is used to define a reference.

For example:

int ix; /* ix is “real” variable */
int &rx = ix; /* rx is “alias” for ix */

ix = 1; /* also rx == 1 */
rx = 2; /* also ix == 2 */

References can be used as function arguments and return values.

This allows to pass parameters as reference or to return a “handle” to a calculated variable or object.

Check Also

Insertion & Extraction In C++

Insertion is the operation of sending characters to a stream, expressed by the overloaded insertion …