?? string.h
字號:
#ifndef SSTRING_H
#define SSTRING_H
#include<string.h>
#include<iostream.h>
template<int bsz=0>
class SString
{
char buf[bsz+1];
char *s;
public:
SString(const char* S=""):s(buf)
{
if(!bsz)
{
s=new char[strlen(S)+1];
strcpy(s,S);
}
else
{
buf[bsz]=0;
strncpy(s,S,bsz);
}
}
SString(const SString& rv):s(buf)
{
if(!bsz)
{
s=new char[strlen(rv.s)+1];
strcpy(s,rv.s);
}
else
{
buf[bsz]=0;
strncpy(s,rv.s,bsz);
}
}
SString& operator=(const SString& rv)
{
if(&rv==this) return *this;
if(!bsz)
{
delete s;
s=new char[strlen(rv.s)+1];
}
strcpy(s,rv.s);
return *this;
}
~SString()
{
if(!bsz) delete []s;
}
int operator==(const SString& rv)const
{
return !strcmp(s,rv.s);
}
int operator!=(const SString& rv)const
{
return strcmp(s,rv.s);
}
int operator>(const SString& rv)const
{
return !stricmp(s,rv.s)>0;
}
int operator<(const SString& rv)const
{
return stricmp(s,rv.s)<0;
}
char *str()const{return s;}
friend ostream& operator<<(ostream& os,const SString<bsz>& S)
{
return os<<S.s;
}
};
typedef SString<> Hstring;
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -