2

Why do you have to use pointers in C++? Why doesn't C++ have a good garbage collector? Surely it has to be more advanced than C it has two more +s.....

Comments
  • 1
    You can implement your own with smart pointers.
  • 1
    I always asked it myself, but I think that the problem is not of the programming language but of the operating system below it. Memory management is a task of the operating system, so if C++ would implement a garbage collector that works on windows 7, it could not work on windows 8 and surely doesn't work on Linux and Max OSx. If windows would implement an automatic algorithm to catch memory issues, it could cause problems of compatibility with old software. So I think that the question it's not as simple as it can appear. The best solution is to create a new programming language to prevent problems of backward compatibilty, and it's what happened (for example with C#) but obviously these languages are sewn upon a single operating system and can run on others.
    Sorry for the long and simplistic answer
Add Comment