谁能帮我写个c++程序?急要!!!

来源:百度知道 编辑:UC知道 时间:2024/09/21 13:50:46
这个程序,是字符串运算符重载的!
1赋值运算符,用=号来实现!
2连接运算符,用+号来实现!
3关系运算符,用>号来实现!
我对运算符毛里重载不会,还望高手们能帮我个忙,学想好C++
写个整个程序给我,我自己慢慢看!谢谢!如果对我的要求不明白,可以问我.我说详细点!

#include <iostream>
using namespace std;
#include <cstring>

class Str{
char * str;//指向保存字符串的空间
int len;//空间的大小
public:
Str();//无参构造,初始化成零长度字符串
Str(const char* sz);//用指定字符串初始化
Str(const Str&);//拷贝构造函数
~Str();//析构函数,清理空间
int Size() const;//取得字符串长度
Str& operator=(const Str&);//对象间赋值
friend Str operator+(const Str&,const Str&);
Str& operator+=(const Str&);//追加一个字符串
operator int()const;//类型转换函数
friend bool operator==(const Str&,const Str&);//字符串比较
friend ostream& operator<<(ostream& o, const Str&);//输出
friend istream& operator>>(istream& i,Str&);//输入
friend int operator >(const Str &s1,const Str &s2){return strcmp(s1.str,s2.str)>0;}
};
Str::Str()
{
len=100;
str = new char[100];
//if( str==NULL ){...}
str[0]='\0';//zero-length string
}
Str::Str( co