Created
November 10, 2017 04:40
-
-
Save honestcomrade/b0e3b3d48b036d5e1c5e1c02d7426179 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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