C++: Stream Operators, Assignment Operators, & Copy-and-Swap
C++
| Expert
- 12 videos | 1h 25m 29s
- Includes Assessment
- Earns a Badge
The stream insertion and extraction operators are often overloaded because they provide a convenient way to read objects in and write objects out to standard IO. The copy assignment operator is even more crucial because of how important it is in correctly freeing up resources held by an object. In this course, learn how to implement the correct overloads of the insertion and extraction operators and why these are invariably implemented as non-member functions. Then, move on to correctly overloading the copy assignment operator and using standard formats to ensure that resource cleanup occurs exactly once. Finally, find out how the copy-and-swap idiom provides a way to use the std::swap function to implement the copy assignment operator in a manner that is exception-safe. This idiom leads to an elegant implementation that is not only less complex, but also more robust.
WHAT YOU WILL LEARN
-
Discover the key concepts covered in this courseUse insertion and extraction operatorsUse insertion and extraction operators as functionsOverload the insertion and extraction operatorsInstantiate objects and use the default copy assignment operatorOverload the copy assignment operator
-
Differentiate when the copy constructor should be used and when the copy assignment operator should be usedRecognize common issues with the default copy assignment constructor including the inability to copy objects storing pointersOverload the copy assignment operatorUse the copy-swap idiom to write exception safe codeCreate copy assignment operators using the copy-swap idiomSummarize the key concepts covered in this course
IN THIS COURSE
-
1m 42s
-
10m 17s
-
8m 28s
-
9m 42s
-
8m 51s
-
8m 59s
-
6m 54s
-
6m 27s
-
6m 58s
-
9m 13s
-
5m 8s
-
2m 51s
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.