Skip to content

Instantly share code, notes, and snippets.

@honestcomrade
Created November 10, 2017 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honestcomrade/b0e3b3d48b036d5e1c5e1c02d7426179 to your computer and use it in GitHub Desktop.
Save honestcomrade/b0e3b3d48b036d5e1c5e1c02d7426179 to your computer and use it in GitHub Desktop.
// overload_date.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
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 << dt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment