Help, please, to understand the program. I study C ++ and have reached operator overload. I need to do the following: implement the Date class, which will store the day, month, and year, initialize this class, and also overload the << operator to display this date in the format (1, 1, 2000). The class I implemented and overload too, but gives an error and I can not help it.
PS Operator overloading needs to be implemented in a class, not outside (if possible)
The code itself: `
class Date { int day; int month; int year; public: Date(int d, int m, int y) : day {d}, month {m}, year {y} { } int getDay() { return day; } int getMonth() { return month; } int getYear() { return year; } ostream &operator<<(ostream &os) { return os << '(' << getDay() << '.' << getMonth() << '.' << getYear() << ')' << endl; } }; int main() { Date dd {10, 10, 2010}; cout << dd; return 0; } `
Mistake:In function 'int main()': error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'Date') cout << dd; ~~~~~^~~~~