Domanda di colloquio di Bloomberg

how does a reference counting smart pointger work?

Risposta di colloquio

Anonimo

4 gen 2010

I remeber the smart pointer is a class with a pointer member which points to the actual object and a counter member to record how many pointers point to the object. If the number of the counter is 0, then call the destructor function to delete the object. This smart pointer is to provent dangle pointer.