int *a=new int[n]
cout<<sizeof(a);
it give 8 not 4 why?
and also pointer hold address first line may be written like int *a=&new int[n]; but why not & is used
About size of dynamic
int *a=new int[n]
cout<<sizeof(a);
this will give you 8 because you are printing size of a pointer
you will get 4 if you print size of integer variable
int a=10;
cout<<sizeof(a); // this will give 4
int a=4;
int *b=&a;
cout<<sizeof(b);// this will also give 8 as it is pointer
char var=‘a’;
char *ptr=&var;
cout<<sizeof(ptr)<<endl; // this will also give 8 as it is also pointer
int *a=new int[n] ;
this cannot be written like int *a=&new int[n]
because new keyword is throwing back the address of dynamically allocated memory