2020-03-01 00:21:26 +00:00
|
|
|
// Declare a pointer variable called iPtr pointing to an int (an int pointer)
|
|
|
|
// It contains an address. That address holds an int value.
|
|
|
|
int *int_Ptr;
|
2017-07-18 00:58:18 +00:00
|
|
|
|
2020-03-01 00:21:26 +00:00
|
|
|
// Declare a pointer of type double.
|
|
|
|
double *double_Ptr;
|
|
|
|
|
|
|
|
// Initializes a to the integer value 5
|
|
|
|
int a = 5;
|
|
|
|
// Set int_Ptr which is an int pointer to the address of `a`.
|
|
|
|
int *int_Ptr = &a
|
|
|
|
// Returns the address of `a`.
|
|
|
|
std::cout << int_Ptr;
|
|
|
|
// Returns 5 because it dereference the pointer to retrieve the value of `a`.
|
|
|
|
std::cout << *int_Ptr;
|