The Overloading of Operator << and >>

class String {
public:
    friend ostream& operator<<(ostream&, const String&);
    friend istream& operator>>(istream&, String&);
    //other members
private:
    char *str;
};

ostream& operator<<(ostream& os, const String& str){
    int i=0;
    while (*(str.str+i)!='\0') os<<*(str.str + i++);
    return os;
}

istream& operator>>(istream& is, String& str){
    is>>str.str;
    return is;
}