Smart pointer

Smart pointers or smart pointers are used in many popular programming languages ​​such as C . There are special pointers over simple pointer variables equipped with additional functions and features. So Smart pointers extend simple pointer and equip them with more functionality out, but can be used like normal pointer variables.

Example

To prevent accidental erasure of memory areas is still referenced by one or the other hand, use referenzzählende pointer. For this, the smart pointer contains a counter variable which is incremented for each copy of the pointer. Try now a part of the program free the memory pointed to by the pointer, the value of the counter variable is first lowered. When the counter reaches the value 0, the memory is released (→ reference counting ).

413810
de