Whats the difference? Pointer to an array vs regular array

后端 未结 9 1753
梦如初夏
梦如初夏 2021-01-04 21:40

I\'m familiar with Java and trying to teach myself C/C++. I\'m stealing some curriculum from a class that is hosting their materials here. I unfortunately can\'t ask the tea

9条回答
  •  爱一瞬间的悲伤
    2021-01-04 22:33

    Dynamically allocated:

    int * pointerArray = new int[10]; 
    

    [BTW, this is a pointer to an array of 10 ints, NOT a pointer array]

    Statically allocated (possibly on the stack):

    int array[10]; 
    

    Otherwise they are the same.

提交回复
热议问题