课程: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

The move assignment operator

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…

内容