What are Pointers in C++ (Object Oriented Programming) ?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Pointers are used to store memory address values of objects. C++ defines a special address-of operator that when applied to an object returns that object’s address value.
E.g. int *pint; //this defines a pointer variable
In order store the address of the variable ‘j’ into pint one should assign the address of j into pint variable as follows:
pint = &j; // assigning the address of variable j into pointer pint
In order to access the actual object pint addresses we must first dereference pint using the dereference operator (*).
*pint = *pint + 1; // this statement will increment the value pint points to by 1
The type of the pointer variable should be the same as the variable whose address it is used to hold. E.g. you cannot define a pointer variable of type float and use it to assign the address of a variable of type integer
Related Articles
- What do you mean by “Pointers to Function”? What are Function Pointers ?
- What is Scope Resolution Operator in C++?
- What is a NULL pointer? How is it different from an unitialized pointer? How is a NULL pointer defined?
- What is CTS ?
- What are the Storage Types for Variables in C++ ?


