If I want to allocate memory dynamically to an int
object, I can do this:
int *x = new int;
In this case, I know that the heap reseves 4-bytes
of memory for an int
object.
But, if I have a user-defined
class (type) and wanted to allocate memory dynamically, as follows:
Car *c = new Car;
How can I know the required amount of memory to be reserved on the heap for a Car
object?
Thanks.