course content

Course Content

Introduction to C++


A variable of a pointer type is declared like a regular variable, but the data type will be with the "*" symbol, for example:


Names of pointers are usually called with the letter "p" (pointer).

Modifying the example from the previous section:



The type of the pointer and the type of the value it points to must be the same.

The pointer variable contains only the address! Therefore, if we try to output a pointer to the console, the program will display the address.

If the pointer is an address (&variable), then to "pass to the address", you need to use the "*" operator.



If you don't initialize a pointer, it will contain a random value (in our case - random memory area), so pointers are grounded before use with a nullptr (NULL pointer) value.


In the first example, we didn't use nullptr because we gave the pointer an address on the next line.

Section 6.

Chapter 3