10 C++ tips that will improve your coding

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.

Learn Why

Tip 2. Declare a virtual destructor if and ONLY if you are using a virtual function in your class.

Learn Why

Tip 3. Always initialize all C++ objects before you use them.

Learn Why

Tip 4. Never call a virtual function during construction or destruction.

Learn Why

Tip 5. Know when you should use delete and when to use delete[]

Learn Why

Tip 6. Use Const whenever possible.

Learn Why

Tip 7. References are aliases. They are NOT pointers.

Learn Why

Tip 8. Use Smart Pointers to avoid memory leaks.

Learn Why

Tip 9. Delay object construction until they are needed.

Learn Why

Tip 10. Don't return a reference when you must return an object.

Learn Why

PS. Sign up to my newsletter and get development tips

Harold Serrano

Computer Graphics Enthusiast. Currently developing a 3D Game Engine.