XII-B-CS (A NOTE ON--POINTER)--PART 2
new operator Syntax: pointer variable = new data_type; Example: char *cptr; cptr = new char; char *captr; captr = new char[10]; delete operator Syntax: delete pointer variable ; Example: delete cptr; delete [] captr; C++ has the concept of constant pointer and pointer to a constant. For example: char * const cptr1="Computer Science"; //constant pointer Here the address of cptr1 cannot be modified. int const *iptr=&x; // pointer to a constant const char * const cptr2="KV"; // pointer to a constant Here the constant value, to which the pointer pointing to, can not be modified. A NULL pointer is a pointer which indicates that it is not pointing to any valid memory address. For example: int *iptr=NULL; Pointer Arithmetic: Only addition and subtraction may be performed on pointers. All the pointers increases and decreases by the length of the data type they point to. Adding 1 to a pointer adds the size of ...