Does C++ have a Garbage Collector?

Native C++ by default has no such thing (the closest thing to this are the smart pointers, but that’s still something entirely different), but that doesn’t prevent you from writing your own garbage collection solution (or using third party solution).

Managed C++ (and its successor C++/CLI) of course use .NET garbage collection for managed resources (though native resources are not garbage collected and have to be managed manually as in native C++).

Leave a Comment