There is a data structure Date

class Date{ int day; int month; int year; } 

It is necessary to overload the operator offset >> to enter the date.

So it is possible with a string, but not a flag?

 void input(istream& in){ string str; in >> str; day = ((int)str[0] - 48) * 10 + ((int) str[1] - 48); month = ((int)str[3] - 48) * 10 + ((int) str[4] - 48); year = ((int)str[6] - 48) * 1000 + ((int) str[7] - 48) * 100 + ((int)str[8] - 48) * 10 + ((int)str[9] - 48); } 
  • The input example should be approximately: 04/26/2000, as a result of which day = 26, month = 4, year = 2000. - pervokursnik
  • Have you tried to do something? If so, can you show the code? It sounds easy: read to std::string , then go through the string character by character. - HolyBlackCat
  • Input operator is not an offset - AR Hovsepyan
  • By default classes, the fields / methods are private, set access, or use a structure. - LLENN

1 answer 1

 istream& operator >>(istream& is, Date& d) { is >> d.day; is.get(); is >> d.month; is.get(); is >> d.year; return is; } 

in a programme:

 Date d; cin >> d;