/* Date.h */ #ifndef DATE_H_ #define DATE_H_ class Date { public: Date(); // constructor void setDate( int, int, int ); // set day, month, year friend ostream & operator<<(ostream &, Date &); // print date format "month dd, yyyy (example: January 11, 2013) friend istream & operator>>(istream &, Date &); // to read date private: int day; int month; int year; // }; #endif /* DATE_H_ */ |
Date.cpp #include "Header.h" #include <iostream> using namespace std; Date::Date(); void Date::setDate( int d, int m, int y ) { day=d; month=m; year=y; } ostream & operator<<(ostream & out, Date & x) { out<< x.month << " " << x.day << ", " << x.year ; return out; } istream & operator>>(istream & in, Date & x) { in>> x.day >> x.month >> x.year ; return in; } |
date.cpp(7): error C2761: '{ctor}' : member function redeclaration not allowed |