Some programmers cope the code fragments forgetting to change the necessary names and values. Others aren’t attentive reading the documentation, which gives a description of a function, or even don’t look at the documentation, hoping that the intuition won’t fail them. Others make the code too complex by creating macros in those fragments where simple functions could work well. There are plenty more examples like these ones.
Of course it’s impossible to warn about all the possible ways to make an error, but it would be quite real to draw the attention to the most common error patterns. At least a person will know the variety of wrong paths to take and will be more careful, which will save time during the debugging and testing.
There are plenty of resources that can help:
- Google coding standard: one of the best, to my mind. Google C++ Style Guide
- Must-read for every programmer. C++ Core Guidelines
- Practical tips: The Ultimate Question of Programming, Refactoring, and Everything (PDF file)
- It’s a good idea to visit C++ community https://isocpp.org/
- For those who aren’t familiar with the novelties of C++: Bjarne Stroustrup’s FAQ
Of course, it is be a drop in the ocean of useful information, but perhaps it would be enough to read during a weekend. Enjoy!