I have a string class at the below:
class Mystring
{
private:
char *letter;
public:
friend ostream & operator <<(ostream &out, const Mystring& s);
friend istream & operator >>(istream &in,Mystring& s);
};
this is in the main function:
int main()
{
Mystring s[10];
cin.get(s,10);
cout << s;
_getch();
return 0;
}
when i use cin.get i get error like this
Error 1 error C2664: 'std::basic_istream> &std::basic_istream>::get(std::basic_streambuf> &,_Elem)' : cannot convert argument 1 from 'Mystring' to 'char *' c:\users\thai\documents\visual studio 2013\projects\overloading\overloading\main.cpp 11 1 Overloading
i think i should create an overloading for cin.get()
, but how ??
Aucun commentaire:
Enregistrer un commentaire