Reference Variable in C++.

Q26. What is a reference variable? How is it defined in C++?

Ans. A reference is an alternative name for a object. A reference variable provides an alias for a previously defined variable. A reference declaration consists of a base type, an & (ampersand), a reference variable name equated to a variable name (previously define). The general form of declaring a reference variable is:

type & ref-var = var-name;

where type is any valid C++ data type, ref-var is the name of reference variable that will point to variable denoted by var-name.

Leave a Reply

Your email address will not be published. Required fields are marked *

57 Views
%d bloggers like this: