This morning I felt like sharing with you some very helpful C++ tips that will improve the way your code and also improve the efficiency of your app. Most of these tips come from the book Effective C++ written by Scott Meyers. Other tips are from random resources I have come across with.
I hope you enjoy them.
Tip 1. Don't use using namespace std.
Tip 2. Declare a virtual destructor if and ONLY if you are using a virtual function in your class.
Tip 3. Always initialize all C++ objects before you use them.
Tip 4. Never call a virtual function during construction or destruction.
Tip 5. Know when you should use delete and when to use delete
Tip 6. Use Const whenever possible.
Tip 7. References are aliases. They are NOT pointers.
Tip 8. Use Smart Pointers to avoid memory leaks.
Tip 9. Delay object construction until they are needed.
Tip 10. Don't return a reference when you must return an object.
PS. Sign up to my newsletter and get development tips