I've been trying to implement an input member function for a Date class.Here's what I have:
class Date {
int year_;
int mon_;
int day_;
int readErrorCode_;
int value()const;
void errCode(int errrorCode);
public:
std::istream& read(std::istream& istr);
std::ostream& write(std::ostream& ostr)const;
}
std::istream& Date::read(std::istream& istr) {
istr.get(year_,5);
return istr;
}
I want to extract 4 characters from input and save it in my parameter year_ for my Date class, but I got an error for the istr.get, I wonder why istr.get does not work while cin.get works.
Error message is: no instance of overloaded function "std::basic_istream::get[with _Elem=char, _traits]" matches the argument list argument types are (int,int) object type is: std::istream