Let\'s say I have:
class A{
public:
int x;
int y;
};
And I allocate an A instance like:
A *a = new A();
You will get one allocation on the heap that contains x
and y
. A
is just a nice way to refer to that object.
I wish I could easily draw on Stack Overflow, but you can think of it something like this (very small) heap example:
+-------------------------------+
| Heap |
+-------------------------------+
| Other memory here ... |
+-------+-----------------------+
A *a -> | x | y | Other memory here ... |
+-------+-----------------------+