VARIABLES
A variable is an abstraction of a memory cell. These are named memory locations used to store a value. The address of a variable can be easily obtained by Address-of Operator(&).
int num;
cout<< #
POINTERS
Pointer is a powerful mechanism in C++ programming. Pointers are special variables that contains the address of another variable.
A pointer is declared as following:
int *int_ptr;
char *char_ptr; float *float_ptr;
After declaration, we can assign address of variables to a pointer.
int num=10;
int_ptr = #
char ch='a';
char_ptr = &ch;
float val=3.25;
float_ptr = &val;
A fundemental operation on pointers in Dereferencing i.e. referring to the object pointed by that pointer.
cout<< *int_ptr; //10
cout<< *char_ptr; //a
cout<< *float_ptr; //3.5
1 comments :
commentsThanks a ton for this.
Reply