© Will Briggs 2021
W. BriggsC++20 for Lazy Programmershttps://doi.org/10.1007/978-1-4842-6306-8_18

18. Exceptions, Move Constructors and =, Recursion, and O notation

Will Briggs1  
(1)
Lynchburg, VA, USA
 

One needful thing – a better way of handling error conditions – and a few very-nice-to-haves: more efficient copying (“move” functions), functions that call themselves (recursion), and a way to figure how time-efficient your functions are.

Exceptions

How should a program handle runtime errors? Some options:
  • The ostrich algorithm: Simply hope the problem will never occur – your integers never exceed INT_MAX, your calls to strcpy never overrun the char array, and so on. We do it a lot, and it works! Shall we try it in software for a nuclear reactor? For ...

Get C++20 for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.