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, ...

Get Learn C++ for Game Development 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.