1.

Justify the following statements 1. In C++, the ‘delete’ operator performs the reverse action of ‘new’ operator. 2. If ‘arr’ is the name of an array, then arr++ is not a valid statement 3. If ‘k’ is a long variable with address 1001 and it is stored by a pointer variable ‘p’, then ‘p + 1 ’ will point to the location with address 1005.

Answer»

1. In C++, the ‘delete’ operator performs the reverse action of ‘new’ operator. In C++, both ‘new’ and ‘delete’ operators are used for dynamic allocation and deallocation of memory respectively, ie. For allocation of memory at runtime new operator is used. For deallocation of memory that have been allocated by the new operator, ‘delete’ operator is used. 

2. arr++ is not a valid statement. Because the base address of an array can not change. Array name gives the base address of the array. 

3. Pointer variable hold the address of memory location where the data is stored. So incrementing the pointer variable is adding the size of the data type. Long data type takes 

4 bytes of memory. So incrementing the pointer variable P makes it point to the address 1005.



Discussion

No Comment Found