Difference between () and [] in pointers

Hi

I am new to C++.


int * a= new int[10];
int * b=new int(89) ;

Here what does 10 specifies in the first statement and what does 89 specifies in the second one.

Thanks
Regards
Karan
Last edited on
I'll hazard a guess then I'll go away and check what I say is correct :-)int * a= new int[10]; says you want 10 integers which will be initialised with the dafault constructor which for inegers does nothing so they will have random values.

int * b=new int(89) syas you want 1 integer initialised to value 89.

That is because the () signifies a call to a constructor.

I'll now go away and check :-)

Topic archived. No new replies allowed.