Dynamic memory in C++

0 Rehman . · July 5, 2015
Is dynamic array always initialized with pointer ?

if yes then why we need pointers only to make dynamic array?

            int *input = new int[size];

well i know i can ask for the "size" to the user when program starts, but i was finding a way that is it possible that user defines at the run time whether program should stop taking input or continue.

Post a Reply


Oldest  Newest  Rating
+1 K D · July 8, 2015
Pointers can be used for so much more then just arrays.  Especially when you start learning about more advanced data structures.  Data Structures like Binary Trees and Linked Lists in C and C++ rely heavily on pointers.  You have only just scratched the surface of what you can do with pointers... :)

Hope this helps

Keep in mind the fact that because you have direct access to the memory locations it opens the door for a lot of new "Bugs".  "With Great Power comes Great responsibility" as you will see when you get deeper in.:)
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator