Why cant dynamically allocated variables can’t be defined at compile time?

Why? I just dont get it...

Im a noob at c++.
That's the point of dynamically allocated variables
use static if you want to define at compile time
Lets say, you have to go from one city to another but you don't know how much is the distance. Can you fill you vehicle with exact quantity of fuel which will be used ?
What you would do is, keep filling the fuel as it is required on the way..

this is the idea of dynamically allocated variables. You allocate memory as it is required at run time because you don't know how much data would be coming. Sometimes it can be 100kb and sometime it could be 100mb of data. At compile time you cannot know how much memory to allocate.
Topic archived. No new replies allowed.