#include <iostream>
using namespace std;
int & fonksiyon(int&);
class Date
{
int mo, da, yr;
public:
Date(int m, int d, int y)
{
mo = m; da = d; yr = y;
}
friend ostream& operator<<(ostream& os, const Date& dt);
};
ostream& operator<<(ostream& os, const Date& dt)
{
os << dt.mo << '/' << dt.da << '/' << dt.yr;
return os;
}
int main()
{
Date dt(5, 6, 92);
cout <<"Date:" << dt << ".";
}
I thought about this thing much,and searched for a good explanation on web too,but I couldn't find what I need,and I'm bored.
The thing which I don't understand is:
ostream& operator<<(ostream& os, const Date& dt);
ostream& os is a reference for cout I think ,operator << function takes cout as an argument I think.
Then what does :
return os;
do?