Sumit Chawla wrote:
> On 7/23/07, parrot_rabbit4u <[EMAIL PROTECTED]> wrote:
>>   I have a doubt regarding "SMART POINTERS" in c++. What is it?
>> where it is used . In google I read abt it as "smart pointers are
>> objects which store pointers to dynamically allocated objects".what is
>> diff between "smart pointer and void pointer".
>>
>> Any one plz answer my question

Usually implemented with a template.  Safe C++ Design Principles (free 
e-book for list members in the Files section - I'm the author) has a 
working Smart Pointer implementation (SmartPtr).


> Google gave this
> http://en.wikipedia.org/wiki/Smart_pointer
> 
> I would say that Smart Pointers are used to avoid the Pointer related
> crashes... however..i personally feel that its better to crash your
> application rather than not knowing what went wrong were....

You can still crash applications using smart pointers.  What won't 
happen is the pointer won't mysteriously vanish if you use it in 
multiple objects.  It uses ref-counting (reference counting) to track 
usage of the pointer.  And when the count reaches zero (nothing is 
referencing the pointer), it is automatically deleted and the memory the 
pointer pointed to is freed.  Similar to garbage collection in other 
languages.

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to