How come "new test()" allocates memory for an object of class test?
Instructions: Fill in the blanks to declare a class "test" with a "foo()" public member function. Declare a pointer "myPtr" to "test" and call "foo()" via the pointer. ----------------------------------- Code (with blanks filled in): class test{ public: void foo() {} }; test* myPtr = new test(); myPtr -> foo(); ---------------------------------- I'm not following the last two lines of code. Why test*? What is new test() and what does it do? Isn't "test" a class; how can it have parameters? Also, the arrow selection (->) and type of pointer (test*) strongly suggest that the part "new test()" is an object of class test, but I'm not understanding this. Please explain. I get that we're assigning memory in the heap and calling it test(), but what precisely is test()? And why do we use "test*" for the pointer initialization, and how can we use "->" to call the foo() function of the pointer? Thank you.