31 nooby C++ habits you need to ditch
How many nooby C++ habits do you have? Up your C++ skill by recognizing and ditching these nooby C++ habits. Post how many you fell for! ā mCoding with James Murphy (https://mcoding.io) Source code: https://github.com/mCodingLLC/VideosSampleCode C++ Core Guidelines: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines SUPPORT ME ā --------------------------------------------------- Patreon: https://patreon.com/mCoding Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE Other donations: https://mcoding.io/donate Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, John Martin, Casey G, Pieter G, Krisztian M, Mutual Information, Sigmanificient BE ACTIVE IN MY COMMUNITY š --------------------------------------------------- Discord: https://discord.gg/Ye9yJtZQuN Github: https://github.com/mCodingLLC/ Reddit: https://www.reddit.com/r/mCoding/ Facebook: https://www.facebook.com/james.mcoding CHAPTERS --------------------------------------------------- 0:00 Intro 0:13 #1. using namespace std 0:42 #2. using std endl in a loop 0:55 #3. index based for when range-for fits better 1:10 #4. rewriting std algorithms 1:34 #5. using C array over std array 1:50 #6. any use of reinterpret cast 2:39 #7. casting away const 3:24 #8. not knowing map bracket inserts element 3:39 #9. ignoring const-correctness 3:59 #10. not knowing string literal lifetime 4:12 #11. not using structured bindings 4:47 #12. out-params instead of returning a struct 5:04 #13. not using constexpr 5:21 #14. forgetting to mark destructor virtual 6:10 #15. thinking class members init in order of init list 6:37 #16. not knowing about default vs value initialization 7:28 #17. MAGIC NUMBERS 7:41 #18. modifying a container while looping over it 8:30 #19. returning std move of a local 9:10 #20. thinking std move moves something 9:42 #21. thinking evaluation order is left to right 10:56 #22. unnecessary heap allocations 11:23 #23. not using unique ptr and shared ptr 12:11 #24. not using make unique and make shared 12:23 #25. any use of new and delete 12:52 #26. any manual resource management 13:24 #27. thinking raw pointers are bad 14:25 #28. using shared ptr when unique ptr would do 14:48 #29. thinking shared ptr is thread-safe 15:26 #30. mixing up const ptr vs ptr to const 16:00 #31. ignoring compiler warnings