C++: Stream Operators, Assignment Operators, & Copy-and-Swap

C++ 20    |    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 course
    use insertion and extraction operators
    use insertion and extraction operators as functions
    overload the insertion and extraction operators
    instantiate objects and use the default copy assignment operator
    overload the copy assignment operator
  • differentiate when the copy constructor should be used and when the copy assignment operator should be used
    recognize common issues with the default copy assignment constructor including the inability to copy objects storing pointers
    overload the copy assignment operator
    use the copy-swap idiom to write exception safe code
    create copy assignment operators using the copy-swap idiom
    summarize the key concepts covered in this course

IN THIS COURSE

  • Playable
    1. 
    Course Overview
    1m 42s
    UP NEXT
  • Playable
    2. 
    Using Insertion and Extraction Operators
    10m 17s
  • Locked
    3. 
    Using the << and >> Operators as Functions
    8m 28s
  • Locked
    4. 
    Overloading Insertion and Extraction Operators
    9m 42s
  • Locked
    5. 
    Using the Copy Assignment Operator
    8m 51s
  • Locked
    6. 
    Implementing the Copy Assignment Operator
    8m 59s
  • Locked
    7. 
    Comparing Copy Constructor to Copy Assignment
    6m 54s
  • Locked
    8. 
    Exploring Default Assignment Operator Issues
    6m 27s
  • Locked
    9. 
    Overloading the Copy Assignment Operator
    6m 58s
  • Locked
    10. 
    Using the Copy-Swap Idiom
    9m 13s
  • Locked
    11. 
    Creating Copy Assignment Operations with Copy-Swap
    5m 8s
  • Locked
    12. 
    Course Summary
    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 of this course, which can be shared on any social network or business platform

Digital badges are yours to keep, forever.