Pointer Help Please

What exactly is the difference between these two? If I try to cout each one I get 0 and 5 respectably. So does the first one initialize an array of 5 elements and sets them to 0? What about the second one, does it only initialize one int and sets that to 5 I'm guessing? Can someone please confirm and elaborate. Thanks
1
2
3

    int *secret= new int[5];
    int *quiet= new int(5);
I'm new to C++ and VERY new to pointers... but I'll take a stab at it.


int[5]; sets up for 5 integers to work with. Like an array a[5] = {1,2,3,4,5} 5 elements.

int(5); sets *quiet to the value of 5, like you pass an argument in a function
Last edited on
Topic archived. No new replies allowed.