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

C++    |    Expert
  • 12 videos | 1h 25m 29s
  • Includes Assessment
  • Earns a Badge
Rating 4.5 of 11 users Rating 4.5 of 11 users (11)
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

  • 1m 42s
  • 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 on some of our courses, which can be shared on any social network or business platform.

Digital badges are yours to keep, forever.

PEOPLE WHO VIEWED THIS ALSO VIEWED THESE

Rating 4.0 of 7 users Rating 4.0 of 7 users (7)
Rating 4.5 of 103 users Rating 4.5 of 103 users (103)
Rating 4.6 of 16 users Rating 4.6 of 16 users (16)