i'm trying to do a simple istream operator overloading, but for some reason, once entering this function, the program enters an infinite loop. please help!
my code:
#include <iostream>
#include <string>
using namespace std;
class date{
int m_day,m_month,m_year;
public:
date(int day=1,int month=1,int year=2000){ //constructor
if (day>0 && day<32 && month>0 && month<13){
m_day =day;
m_month=month;
m_year=year;
}
}
friend ostream& operator<< (ostream& out, const date& d);
friend istream& operator>> (istream& in, const date& d);
};
istream& operator>> (istream& stream, const date& d){ //overload >>
stream >> d.m_day;
return stream;
}
void main(){
date date1;
cin>>date1; //check istream
getchar();
}