2. Stream InsertionStream Insertion
operatoroperator
โบOften we need to display the dataOften we need to display the data
on the screenon the screen
โบExample:Example:
int i=1, j=2;int i=1, j=2;
cout << โi= โ<< i << โnโ;cout << โi= โ<< i << โnโ;
Cout << โj= โ<< j << โnโ;Cout << โj= โ<< j << โnโ;
3. Stream InsertionStream Insertion
operatoroperator
Complex c1;Complex c1;
cout << c1;cout << c1;
cout << c1 << 2;cout << c1 << 2;
// Compiler error: binary '<<' : no// Compiler error: binary '<<' : no
operator // defined which takes a right-operator // defined which takes a right-
hand // operand of typehand // operand of type โโclassclass