What are Pointers in C++ (Object Oriented Programming) ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

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


Get Latest JobsAdda.com Jobs, news & updates  via Email