Where does a list
inside an object gets its stack?
The program below shows a size of the object of 40. So where did the list allocate its memory from?
class TEST
{
public:
TEST(void);
void Push(void);
private:
std::list<int> _list;
std::list<int>::iterator _it;
int f;
};
TEST::TEST(void) : f(1)
{
}
void TEST::Push(void)
{
_list.push_back(f++);
}
main:
{
TEST n;
int a = sizeof(n);
std::cout << a << std::endl;
n.Push();
a = sizeof(n);
std::cout << a << std::endl;
for(int r=0; r<10000; r++){
n.Push();
}
a = sizeof(n);
std::cout << a << std::endl;
}
Output:
40 <br/> 40 <br/> 40