O'Reilly logo

Beginning C++ Through Game Programming, Third Edition by Michael Dawson

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

Chapter 5. Functions: Mad Lib

Every program you’ve seen so far has consisted of one function—main(). However, once your programs reach a certain size or level of complexity, it becomes hard to work with them like this. Fortunately, there are ways to break up big programs into smaller, bite-sized chunks of code. In this chapter, you’ll learn about one way—creating new functions. Specifically, you’ll learn to:

  • Write new functions

  • Accept values into your new functions through parameters

  • Return information from your new functions through return values

  • Work with global variables and constants

  • Overload functions

  • Inline functions

Creating Functions

C++ lets you write programs with multiple functions. Your new functions work just like the ones that are part of ...

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