In programming
In programming
The scope resolution operator is special operator that allows access to global variable that is hidden by a local variable with the same name .
#include<iostream> which is actually hidden by the variables x declared in the outer and inner block
inside main().
using namespace std;
The variable declared inside main() in the inner block overrides both local variable
int x=5;
of outer block and the global variable.
int main()
Thus the global version of variable x is accessed with the help of scope resolution
{ int x=3; operator ::x in the inner and outer block.
{ int x=10;
return 0;
OUTPUT:
the local variable of outer block is 3 the local variable of inner block is 10
The new operator denotes a request for memory allocation on the heap.
If sufficient memory is available the new operator initializes the memory and returns the
address of the newly allocated and initialized memory to the pointer variable.
In C++ new and delete operator performs the task of allocating and freeing memory.