Chapter 5
Functions, the Building Blocks of C++
Modern games consist of hundreds of thousands of lines of code and can be worked on by teams consisting of hundreds of people. C++ provides the ability to separate code into blocks called functions to allow us to build more modular programs.
A function allows us to write a routine that can be reused throughout our program. The benefits of this are significant. You saw this in the last chapter when we looked at some of the C++ functions for working with strings. We did not have to write our own code to determine if two strings were the same; instead, we could simply pass them both into a function and the return value told us the result of the function.
This chapter covers how we write functions, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access