some gentleman please tell me what's going on with my program??
in the String.h ,i will overload the operator <<.....
but something is wrong with the OSTREAM....can't find it....
#include <iostream>
using namespace std;
class String;
istream& operator>>(istream&, String&);
ostream& operator<<(ostream&,const String&);
class String{
//......something else;
public:
char* c_str(){ return _string;}
private:
_string;
};
//this is where the problem is....
inline ostream&
operator<<( ostream &os, String &s)
{
return os << s.c_str();
}
Last edited on
You declared operator << as
ostream& operator<<(ostream&,const String&);
but defined another overloaded operator << as
inline ostream&
operator<<( ostream &os, String &s)