I saw some post about implement GC in C and some people said it\'s impossible to do it because C is weakly typed. I want to know how to implement GC in C++.
I want s
You can read about the shared_ptr struct.
It implements a simple reference-counting garbage collector.
If you want a real garbage collector, you can overload the new operator.
Create a struct similar to shared_ptr, call it Object.
This will wrap the new object created. Now with overloading its operators, you can control the GC.
All you need to do now, is just implement one of the many GC algorithms