So I currently trying to make the output stream insertion operator and trying to make it so it displays the date a certain way but I keep getting the "Attempting to reference a deleted function" error. I am not sure what the issue could be. Any help?
class Date { private: static int day; static int month; static int year; public: static string wordmonth[]; Date(int d, int m, int y) { this->day = d; month = m; year = y; } Date(int d) { this->day = d; } Date() { } void setDay(int d) { this->day = d; } void setMonth(int m) { month = m; } void setYear(int y) { year = y; } int getDay() { return day; } int getMonth() { return month; } int getYear() { return year; } void print1(); void print2(); void print3(); Date operator ++ () { day++; return *this; } Date operator ++ (int) { Date day = *this; ++* this; return day; } Date operator -- () { day--; return day; } Date operator -- (int) { --day; return day; } Date operator - (Date v) { Date temp; temp.day = day - v.day; temp.month = month; temp.year = year; return temp; }; This is the operator that I am trying to get to work.
friend ostream operator << (ostream& output, Date& obj) { output << wordmonth[month - 1] << " " << day << ". " << year; return output; } };
wordmonth, referenced by your overloaded<<operator, you think should be? It can't be thewordmonthclass member, of course, because, as you specified this is a friend function, and not a class member. Only class members can access other class members.static. Why? I think you don't want that.