All pastes #1917296 Raw Edit

and operators Overloading

public cpp v1 · immutable
#1917296 ·published 2010-08-15 09:59 UTC
rendered paste body
//<< and >> operators Overloading#include <iostream.h>class Date{private:	int day, month, year;public:	Date(){}	Date(int m, int d, int y)	{		day=d;		month=m;		year=y;	}	friend ostream& operator<<(ostream& out , Date& date);	friend istream& operator>>(istream& in, Date& date);};ostream& operator<<(ostream& out, Date& date){	out << date.day << '/' << date.month << '/' << date.year <<'\n' ;	return out;}istream& operator>>(istream& in, Date& date){	cout << "\nEnter new date [DD][MM][YY]: \n";	in>>date.day;	in>>date.month;	in>>date.year;	return in;}int main(){	Date today(14, 8, 2010), newday;	cout << "Today's Date: " << today << endl;	cin >>  newday;	cout << "\nThe new date is: " << newday << endl;	return 0;}