class mystring:public std::string
{
public:
mystring(){}
mystring(const char * s)
{
empty();
(*this) += s;
}
mystring(int i)
{
(*this) = i;
}
mystring(double i)
{
(*this) = i;
}
~mystring(){}
mystring & operator = (int i)
{
char buffer[16] = {0};
sprintf(buffer,"%d",i);
empty();
(*this) += buffer;
return *this;
}
mystring & operator = (double i)
{
char buffer[16] = {0};
sprintf(buffer,"%d",i);
empty();
(*this) += buffer;
return *this;
}
friend mystring operator +(const mystring & s1,const mystring & s2)
{
mystring s = s1;
s += s2;
return s;
}
friend mystring operator +(const mystring & s1,const char * s2)
{
mystring s = s1;
s += s2;
return s;
}
friend mystring operator + (const mystring & s1,int i)
{
mystring s = s1;
mystring s2 = i;
s += s2;
return s;
}
friend mystring operator + (const mystring & s1,double i)
{
mystring s = s1;
mystring s2 = i;
s += s2;
return s;
}
};
|