这是我写的一个类,然后定义了MyString mystr;结果编译通过但是不能运行
class MyString {
friend ostream& operator<<(ostream& os, const MyString& s);
friend bool operator==(const MyString& s1, const MyString& s2);
friend bool operator<=(const MyString& s1, const MyString& s2);
friend bool operator>=(const MyString& s1, const MyString& s2);
friend bool operator!=(const MyString& s1, const MyString& s2);
friend bool operator< (const MyString& s1, const MyString& s2);
friend bool operator> (const MyString& s1, const MyString& s2);
public:
MyString()=default;
MyString(const char* s) ;
//copy constructor
MyString(const MyString& s2) ;
~MyString()
{
delete[] str;
}
int size()const {return strlen(str);}
MyString& append(const char*);
MyString& append(MyString&);
char& operatorconst { return str[n]; }
private:
char* str='\0';
};