Hello im having problems reading lines (ignore space characters) in an overloaded Extraction operator
this is my code any assistance would be great
istream& operator>>(istream& is, CreditAccount& Cred){
cout << "Name: ";
is.getline(Cred.name, 256);
}
my error is as follows
error: no matching function for call to ‘std::basic_istream<char, std::char_traits<char> >::getline(std::string&, int)’
we need to know the the type of Cred::name, however from your error it appears to be a std::string. the correct function to use is:
I would also stress, that if you are using
std::coutto prompt the user for input you are not using the stream extraction operator properly, it is for basic serialisation and de serialisation of an objects state. Not for user interaction. I personally would just have a “produce_credit_account()” function or the like.EDIT: to clear
std::cin