Possible Duplicate:
Does this type of memory get allocated on the heap or the stack?
class foo{
private:
int bar;
constructors and other members here...
}
If i create an instance of foo using the new operator where it will be created?
Heap i guess but where does my int bar; get created, stack or heap?
And if my bar wasn’t a primitive data type but another object created like this->bar=bar();, where would it be created?
Read about how class instances are constructed in the memory. Simple explanation here.
The members are a part of the class instance’s chunk in memory. So where ever that class instance is allocated, the whole chunk is allocated, including the members.