2 ms·
The problem is that if you were hit by a bus, the next guy maintaining the code has to know about where everything is cleaned up and has to know all of the secr
by 72deluxe 11y ago
The problem is that if you were hit by a bus, the next guy maintaining the code has to know about where everything is cleaned up and has to know all of the secrets that you know and that you decided you knew better than the compiler in areas. This makes for unmaintainable code.
Ownership is very important because if you don't know who owns it, who will clean it up??
If you don't know how long an object will be around because you've got a pointer, it is now a dangling pointer and attempts to use it will cause chaos. So object lifetime is important too.
The error messages are usually quite helpful. clang's messages are more helpful for gcc, I have found.
C++ is complex, but you can still write safe code without using any of the complexities.