Home >>C++ Tutorial >C++ Pointers
The pointers in C++ programming language is basically a variable that is also called as locater or installer that generally point towards the address of a provided value.
There are many advantages of the pointers, some of them are as follows:
Here are the uses of the pointers in the C++ programming language:
Pointers are used widely in arrays, functions and structures in C++ as they are known to enhance the performance and reduce the code.
Symbol | Name | Description |
---|---|---|
&(ampersand sign) | Address operator | It is used to determine the address of a variable. |
*(asterisk sign) | Indirection operator | It is used to access the value of an address. |
By using the * asterisk symbol, a pointer is declared in the C++.
Syntax
int * a; //pointer to int char * c; //pointer to char
Here are the examples of the pointers that will help you understand the topic better:
#include <iostream> using namespace std; int main() { int num=10; int *p; p= & num; cout<<"Print Address of num variable : "<<&num<<endl; cout<<"Print Address of p variable :"<<p<<endl; cout<<"Print the Value of p variable :"<<*p<<endl; return 0; }