3 ms·
Not with the C++11 by itself but with better compilers we've got since about 2000 (don't forget that the earliest C++ standard is from 1998): 1. Member initial
by pandaman 14y ago
Not with the C++11 by itself but with better compilers we've got since about 2000 (don't forget that the earliest C++ standard is from 1998):
1. Member initialization order being broken in the constructor initialization is a warning pretty much everywhere (except Microsoft compilers, I think).
2. Having a virtual function and no virtual destructor - a warning even in Microsoft compilers.
3. Trivial infinite recursion (i.e. Manager::print() { print(); } is a warning at least in some compilers. I have seen only a handful of projects where such code existed at all so I cannot say how widespread this warning (For me it popped due to problems with scripts generating code, people don't write this stuff ).
This is just from glancing over the article, I am sure if you tried all pitfalls with a modern compiler like clang or even gcc, you'd get a few more warnings.
Though I agree with the main point the author is trying to make - C++ is not just Java with pointers so if you are coming from Java background you should be very careful not to assume the conventions you've got used in Java are the same in C++.
- UnFleshedOne 14y agoI never understood the need for blanket warnings for member initialization order on gcc. 99% of the time the order doesn't matter (who cares if I assign zero to one int or another first). And when it does, it is better to move initialization to the body of constructor anyway. Basically I have to do annoying reordering every time I do some changes on msvc and then compile on gcc just to remove the warnings.