IFD:EAI SoS21/course material/Session 3: File Structuring, Pointers and Addresses: Difference between revisions

From Medien Wiki
Line 26: Line 26:
It's called "stack" because the variables really stack up there, on after the other, depending of the order you instantiate them. The syntax for creating a Point2D as a stack variable is as follows:
It's called "stack" because the variables really stack up there, on after the other, depending of the order you instantiate them. The syntax for creating a Point2D as a stack variable is as follows:


<syntaxhighlight lang="c++" highlight="4" line="noline">Point2D p1 = Point2D(1,2);</syntaxhighlight>
<syntaxhighlight lang="c++" highlight="4" line="none">Point2D p1 = Point2D(1,2);</syntaxhighlight>


If we use pointers however we can use memory space everywhere in the main memory. This space is used by other programs as well and rather loosely organized. This is why it is called "heap".  
If we use pointers however we can use memory space everywhere in the main memory. This space is used by other programs as well and rather loosely organized. This is why it is called "heap".