the "new" operator in c++, pointer question

c++, pointers

Solution

If `new` completes successfully, it always returns a pointer (if it doesn't complete successfully, an exception is thrown, and nothing is returned).

The pointer is to the object that was created, or in the case of an array, a pointer to the first element of the array.

Problem

Dumb question, but whenever you call new, do you always have a pointer? ``` SomeClass *person = new SomeClass(); ``` And is that because you need a pointer to point to that new space of memory that was allocated for the SomeClass variable person? Thanks!

Original source

Related problems