Home > Articles

C++ Coding Standards: Throw by Value, Catch by Reference

  • Print
  • + Share This
  • 💬 Discuss
Catching and Throwing in C++ can be tricky, but this chapter will help you to know when and how to use these functions effectively, as well as when you shouldn't be using them.

Summary

Learn to catch properly: Throw exceptions by value (not pointer) and catch them by reference (usually to const ). This is the combination that meshes best with exception semantics. When rethrowing the same exception, prefer just throw; to throw e; .

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus