Chapter     12

Copying and Assigning Data to Objects

You have seen how we can pass data into functions by value, by reference, or by pointer. If you choose to pass a class object into a function by value, C++ will make a copy of the class. This copy operation happens automatically or implicitly. This chapter is going to show you some of these implicit operations that can occur when using classes in your programs and the ways in which you can alter and manage these implicit operations.

Copy Constructors

Classes in C++ can use constructors and destructors to initialize and clean up the objects that you use in your programs. C++ also allows you to specify a copy constructor that is called when an object is being copied into a new instance of an ...

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.