C++ Tutorial: Overloading Stream Extraction and Insertion Operators [8]

preview_player
Показать описание
In this video, I demonstrate how to overload the stream insertion and extraction operators for use with your classes.

These operators are typically used for cin and cout, and are different than other operators such as +, -, *, etc. They are actually functions defined in the iostream library and so we'll need to overload those function definitions and then make them friends of the class we intend to use them with.

So, in addition to overloading these operators for a sample class, I also show you how to make a function a friend of a class.

This is explained while I'm writing the code for simple, sample class.

So, when we are done, we have an example of C++ operator overloading for a simple class that can then be used with cin and cout.
Рекомендации по теме
Комментарии
Автор

Finally someone who explained this the proper way. Thanks man!!

traian
Автор

So, how does one overload the output operator as a standalone function (non-member non-friend)? It needs to work with out and any of stream object.

propel
visit shbcf.ru