I was asked about the difference in how garbage collection would be handled in Java v. C or C++
Anonymous
First of all there is no garbage collector in C/C++, garbage collector and smart pointers are different things. Smart pointer guarantees destructor invocation right after reference counter becomes equal to zero. Garbage collector guarantees too free memory used by instance with ref counter == 0, but it doesn't says when it will happen. Whatever you always can implement a garbage collector with JVM-like behavior. But most probably interviewer wasn't asking to implement garbage collector in C/C++
Check out your Company Bowl for anonymous work chats.