Difference between revisions of "Intermediate C++ Game Programming Tutorial 6"
(Created page with "This tutorial is epoch-making, DO NOT SKIP IT. The ostensive main topic for this video is destructors, but that is not where its soul lies. After learning about dtors, we are...") |
(→Video Timestamp Index) |
||
Line 28: | Line 28: | ||
* [https://youtu.be/OwDJGrV3pgM?t=16m25s Copy Assignment Operators] | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Copy Assignment Operators] | ||
* [https://youtu.be/OwDJGrV3pgM?t=16m25s Conditions when Copy Ctor Impossible for Compiler to Generate] | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Conditions when Copy Ctor Impossible for Compiler to Generate] | ||
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Copy Constructing with <code>=</code>] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Converting Constructors] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s <code>explicit</code> Constructors] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Calling Constructors with <code>()</code> vs. <code>{}</code>] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Example of a Class that Manages a Resource] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Problem with Using Compiler-Generated Copy Ctor (Shallow Copy Problem)] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Problem with Using Compiler-Generated Copy Assign (Shallow Copy Problem)] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Deep Copy Assign] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Rule of 3] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Rule of 0] |
− | * [https://youtu.be/OwDJGrV3pgM?t=16m25s | + | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Calling Copy Assign from Copy Ctor] |
+ | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Explicitly Deleting Special Functions] | ||
+ | * [https://youtu.be/OwDJGrV3pgM?t=16m25s Homework] | ||
== Source Code == | == Source Code == |
Revision as of 21:40, 15 July 2017
This tutorial is epoch-making, DO NOT SKIP IT. The ostensive main topic for this video is destructors, but that is not where its soul lies. After learning about dtors, we are ready to discuss a matter that is at the heart of C++: RAII. This will form the bridge between low-level memory management, and high level smart objects. We also discuss the important concept of deep copying and the Rule of 3, and related to this, we review the 4 original special member functions. AND there are discussion of a bunch of other random bullshit, like converting construction for example. It's a big video is what I'm tryin' to say here.
Contents
Topics Covered
- RAII (Resource Allocation Is Initialization)
- Deep Copy vs. Shallow Copy
- Rule of 3 / Rule of 0
- Destructors
- Special Member Functions
- Converting Constructors
-
explicit
Keyword for Constructors - Copy Construction with Assignment operator
=
- Constructing with
()
vs. with{}
- Deleting Special Member Functions with
= delete
- Conditions when Special Members Cannot be Generated by Compiler
Notes
Video Timestamp Index
- Announcing Member Functions
- Destructors
- RAII
- Special Member Functions
- Default Constructors
- Conditions when Default Ctor not Defined
- Conditions when Default Ctor Impossible for Compiler to Generate
- Copy Constructors
- Copy Assignment Operators
- Conditions when Copy Ctor Impossible for Compiler to Generate
- Copy Constructing with
=
- Converting Constructors
-
explicit
Constructors - Calling Constructors with
()
vs.{}
- Example of a Class that Manages a Resource
- Problem with Using Compiler-Generated Copy Ctor (Shallow Copy Problem)
- Problem with Using Compiler-Generated Copy Assign (Shallow Copy Problem)
- Deep Copy Assign
- Rule of 3
- Rule of 0
- Calling Copy Assign from Copy Ctor
- Explicitly Deleting Special Functions
- Homework
Source Code
GitHub Repo for tutorial
GitHub Repo for homework (Memesweeper)
Downloads
Homework
Modify Memesweeper so that the array for the field is dynamically allocated depending on play field selection by the user at the beginning of the game. After a game over, the game should be able to return to the menu so that the user can play again without restarting the application.
A menu system and UI has already been implemented for you, all you need to do is figure out how to handle the output from the menu, and then modify the game engine to use dynamic allocation and to reset the field after every game.