course content

Course Content

Introduction to C++

Referencing and Dereferencing OperatorsReferencing and Dereferencing Operators

To use pointers, we only need two operators:

  • reference operator "&" ;
  • dereference operator "*".

Reference operator

The "&" operator returns the address of the memory location that contains the variable.

cpp

main.cpp

Now we can look "under the hood" of variable names. Yes, variable names hide their addresses!

Note

Addresses, as a rule, are presented in hexadecimal notation, that is, the address is specified using 16 characters - the numbers 0-9, and the letters A-F. For example: 0xffffd268a42c.

Dereference operator

The dereference operator "*" allows you to get the value at the specified address:

cpp

main.cpp

Section 6.

Chapter 2