CJCoding With Joseph
15free / daySign inCreate account

makePoint Factory and the Caller Deletes

The Point struct (an int x and an int y) is already written. Finish makePoint so it allocates exactly ONE Point on the heap, stores its two parameters in the x and y members, and returns that pointer. Then, in main, release each Point after it has been printed.

Both cout lines are already written. Print exactly the output shown in Expected Output.

Free the memory you allocate before the program ends — this question checks for memory leaks.

Expected Output:

Point: (3, 4)
Point: (-2, 9)

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.