721
edits
Line 31: | Line 31: | ||
When we create a pointer to our Point2D, the syntax is like this: | When we create a pointer to our Point2D, the syntax is like this: | ||
< | <syntaxhighlight lang="c++" highlight="4">Point2D* p2 = new Point2D(1,2); | ||
... | ... | ||
delete p2;</ | delete p2;</syntaxhighlight> | ||
We need to use the asterisk to denote, that we want to create a pointer and we need to use the "new" keyword to reserve the memory for our Point2D. After the "new" keyword we can initialize our Point2D directly as shown before. | We need to use the asterisk to denote, that we want to create a pointer and we need to use the "new" keyword to reserve the memory for our Point2D. After the "new" keyword we can initialize our Point2D directly as shown before. |