O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summing Up

You now have a complete calculator. It lets you enter an operator and a number and it accumulates the effects of these inputs in a static local variable of a function. It uses the switch statement to determine what to do to the accumulator, based on an operator character entered by the user. When it gets an invalid operator, it throws a Standard C++ library exception (runtime_error) that it handles with a new and separate catch of runtime_error in main(). It reports the exception with a new function in the ErrorHandlingModule.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required