From the course: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
The move assignment operator - C++ Tutorial
From the course: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices
The move assignment operator
- [Speaker] Along with the move constructor. The move assignment operator is also an important part of supporting move semantics in your code. This is container 02.CPP from chapter two of the exercise files. And this version of our container class includes the move constructor that we added in the last video. Now if we come down here into main and we see that we're calling our move constructor, I can run this and we can see the results there. We call the move constructor and then a is empty after that. Instead of this, let's create a container we'll call it container string and say c I need to add the template parameter there because we're going to leave it default constructed. And that means that there's no way for the statement to automatically deduce the type. And then I'm going to say c equals a like this. And then we'll print out a and c like we have been doing there. I'll go ahead and I'll run this and you'll…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.