We use the * operator to obtain and modify the value of the variable being pointed to by the pointer however, we don't use this operator while making arrays using dynamic allocation.Why is it so ?
Ex.
1 2 3 4 5 6 7 8
int * val ;
val = newint ;
cout<<"enter a value : ";
cin>>*val ; //Here we use *
cout<<"The value entered is :"<<*val;
delete val;
1 2 3 4 5 6 7 8 9 10
int *val ,r;
cout<<"Enter size of array :"; cin>>r;
cout<<"Enter element of array : ";
for(int i=0 ; i<r ; i++)
cin>>val[r]; //Here * is not used .
cout<<"enter elements of array are :";
for(int i=0 ; i<r ; i++)
cout<<val[r]<<" "; //Again * is not used .