On 08/ 9/11 04:42 PM, ittium wrote:
> On 04-08-2011 PM 07:51, Juha Nieminen wrote:
>> itt ium<> wrote:
>>> if the vector is of big size, making a local variable will occupy lot
>>> of stack space and may result in stack overflow.
>>
>> Nope. There's a very simple way of seeing how much stack space an
>> object takes, namely:
>>
>> void foo()
>> {
>> std::vector<int> v(10000);
>> std::cout<< "v is taking"<< sizeof(v)<< " bytes of stack space.\n";
>> }
>>
>> Here it says "v is taking 12 bytes of stack space."
>>
>> The rest is allocated on the heap.
>
> This means, we really do not have any situation, where we should define
> STL containers with pointers. Container with normal variables are
> sufficient for most of the cases.
Except where the object is "large", dynamically allocated, isn't
copyable or you don't want to copy it...
--
Ian Collins
|