Skip to content
  • Sign In
  • Try Now
View all events
C++

C++ Essentials: The Special Member Functions

Published by O'Reilly Media, Inc.

Beginner content levelBeginner

Understanding copy and move semantics

Good class design is at the heart of software development with C++, so detailed knowledge about basic class mechanics is indispensable for every professional C++ developer. Essential parts of C++ classes are the fundamental operations for default initialization, cleanup, copying, and moving of instances. These operations are realized by special member functions (SMFs).

Join C++ expert Klaus Iglberger to gain an in-depth understanding on when and how to implement these functions. You’ll learn what the default constructor and the destructor do and zero in on the semantics and implementation details of the copy and move operations.

What you’ll learn and how you can apply it

By the end of this live online course, you’ll understand:

  • The details of default initialization
  • The semantics of the copy constructor and copy assignment operator
  • The semantics of the move constructor and move assignment operator
  • The responsibilities of the destructor
  • When and under which circumstances the C++ compiler generates the SMF
  • How the compiler-generated version of the SMF is implemented
  • When and how to implement the special member functions yourself
  • How to implement proper copy and move semantics
  • How SMFs influence each other

And you’ll be able to:

  • Correctly and reliably initialize class instances
  • Properly clean up class instances
  • Implement correct copy operations for your classes
  • Provide correct and efficient move operations for your classes
  • Avoid the most common pitfalls of the SMF

This live event is for you because...

  • You want to become a professional C++ developer.
  • You want to write good classes in C++.
  • You want to understand one of the most important aspects of classes in C++.

Prerequisites

  • Access to a C++14/17/20 compiler (Microsoft Visual Studio 2015, GNU 4.8, Clang 3.6, or Intel 15.0)
  • Windows with Visual Studio CMake
  • Some basic C++ experience

Recommended follow-up:

Schedule

The time frames are only estimates and may vary according to how the class is progressing.

The default constructor (20 minutes)

  • Presentation: Introduction to the default constructor
  • Q&A

The copy operations (75 minutes)

  • Presentation: Introduction to the copy operations
  • Hands-on exercises: Implement the copy operations for a resource owner; understand the implementation details
  • Q&A
  • Break

The move operations (60 minutes)

  • Presentation: Introduction to the move operations
  • Q&A
  • Break

Implementing the move operations (60 minutes)

  • Presentation: Implementing the move operations of std::unique_ptr
  • Hands-on exercise: Implement the move operations for a resource owner
  • Q&A
  • Break

The destructor (15 minutes)

  • Presentation: Introduction to the destructor; the rule of 0/3/5

Wrap-up and Q&A (10 minutes)

Your Instructor

  • Klaus Iglberger

    Klaus Iglberger is a freelance C++ trainer and consultant who’s been focused on large-scale C++ software design since earning his PhD in 2010. He shares his experience in popular advanced C++ courses in Germany, across the European Union, and in the United States. He’s the initiator and lead designer of the Blaze C++ math library and one of the organizers of the Munich C++ user group.