Address-of Operator

What Does Address-of Operator Mean?

An address-of operator is a mechanism within C++ that returns the memory address of a variable. These addresses returned by the address-of operator are known as pointers, because they “point” to the variable in memory.

Advertisements

The address-of operator is a unary operator represented by an ampersand (&). It is also known as an address operator.

Techopedia Explains Address-of Operator

Address operators commonly serve two purposes:

  1. To conduct parameter passing by reference, such as by name
  2. To establish pointer values. Address-of operators point to the location in the memory because the value of the pointer is the memory address/location where the data item resides in memory.

For example, if the user is trying to locate age 26 within the data, the integer variable would be named age and it would look like this: int age = 26. Then the address operator is used to determine the location, or the address, of the data using “&age”.

From there, the Hex value of the address can be printed out using “cout << &age". Integer values need to be output to a long data type. Here the address location would read "cout << long (&age)". The address-of operator can only be applied to variables with fundamental, structure, class, or union types that are declared at the file-scope level, or to subscripted array references. In these expressions, a constant expression that does not include the address-of operator can be added to or subtracted from the address-of expression.

Advertisements

Related Terms

Latest Data Management Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…