I can't understand the concept behind reference counting!
When and why an object is called reference counted?
Is it some kind of handler, like HWND, HDC etc?
Any info would be appreciated!
I can't understand the concept behind reference counting!
When and why an object is called reference counted?
Is it some kind of handler, like HWND, HDC etc?
Any info would be appreciated!
Devoted my life to programming...
You might want to search the Web concerning "reference counting". Simply put, the idea is to track the (number of) pointers that refer to (and own) an object, usually so that the object can be destroyed when the last such pointer no longer refers to it.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
By way of example, often string classes contain a shared ptr to the data (actual characters) so things that just copy the object don't copy the data too. Only two conditions result in alteration or deletion of the string data: destruction of the final object referencing that data and if any of the string objects related to that data try to alter it (which results in the string being copied first, then altered so the original remains intact). The point of doing this is reducing memory consumption and at the same time speeding program execution, albeit only slightly.
Oh, i think i get the basic idea, but i'll search it a bit to learn more about it.
Devoted my life to programming...