View Single Post
Old 09-29-2016, 05:37 AM   #1
chinmay.sahoo
Registered User
 
Join Date: Dec 2013
Location: Banglore
Posts: 335
Send a message via AIM to chinmay.sahoo Send a message via MSN to chinmay.sahoo
What Are Pointers?

A pointer is a variable that contains a memory address. Very often this address is the location of another variable. For example, if x contains the address of y, then x is said to "point to" y.

Pointer variables must be declared as such. The general form of a pointer variable declaration is

Code:
type *var-name;
Here, type is the pointer’s base type; it must be a valid C++ type. var-name is the name of the pointer variable. For example, to declare p to be a pointer to an integer, use this declaration:

Code:
int *p;
For a float pointer, use
float *p;
In general, in a declaration statement, preceding a variable name with an * causes that variable to become a pointer. The type of data that a pointer will point to is determined by its base type. Here is an example:

Code:
int *ip; // pointer to integers
double *dp; // pointer to doubles
As the comments indicate, ip is a pointer to integers because its base type is int, and dp is a pointer to doubles because its base type is double. As you will see, the base type is very important in pointer operations.



Hair Building Fiber
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
chinmay.sahoo is offline   Reply With Quote