Home > Articles

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

  • Print
  • + Share This
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.
This chapter is from the book


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