No, it is your responsibility to procure deallocation:
int *i = new int;
delete i;
However, the above code will sooner or later evolve into something that is almost impossible to make exception-safe. Better do not use pointers at all, or if you really must, use a smart pointer which will free the memory for you at the right moment:
std::shared_ptr<int> i (new int);
*i = 0xbeef;
return i;
There exist other smart pointers with different ownership semantics.
For most real world application, any imposed or assumed overhead introduced by smart pointers usually gets weight up easily against more expensive (I really mean money-saving) stuff like maintainability, extensibility, exception safety (where all there intermix into the other two).
Never forget that there exist alternatives to pointers, depending on the situation:
- standard containers: If you need things like array
- smart pointers: If you really need a pointer
- references: Which you cannot forget to deallocate
- plain objects: No pointers at all. Rely on copying and moving, which usually makes for a high degree of maintainability, extensibility, exception safety and performance. In C++, this should be your default choice.