Перевантаження оператору вводу (>>)
#include <iostream>
using namespace std;
class Date
{
public:
int d, m, y;
friend istream& operator>>(istream& is, Date& dt);
};
istream& operator>>(istream& is, Date& dt)
{
return is >> dt.d >> dt.m >> dt.y;
}
int main()
{
Date dt;
cout << "Enter d m y: ";
cin >> dt;
cout << dt.d << "." << dt.m << "." << dt.y << endl;
system("pause");
return 0;
}
Enter d m y: 1 1 2075
1.1.2075