Does the memory allocated by the new keyword in a function body
get deallocated when the function goes out of scope? Or do I have
to manually deallocate it with the delete keyword?
Barring the use of auto/smart pointers, you need to associate every call to new with a call to delete. Memory allocated dynamically to raw pointers does not free itself unless explicitly freed or the program terminates.