The program compiles but it only shows the addresses of myDate.year not the year that I input.
#include <iostream>
using namespace std;
class Date
{
friend ostream &operator<<( ostream &, const Date & );
friend istream &operator>>( istream &, const Date & );
private:
int day, month, year;
};
istream &operator>>( istream &in, const Date &myDate)
{
int d, m, y;
cout << "Enter three integers for day, month, year: ";
in >> d >> m >> y;
return in;
}
ostream &operator<<( ostream & out, const Date &myDate)// removed friend
{
out << myDate.day << "/" << myDate.month << "/"
<< myDate.year << endl;
return out;
}
int main()
{
Date lastYear;
cin >> lastYear;
cout << lastYear;
return 0;
}