主要是4个默认函数的重写:
代码:
#include
using namespace std;
class Cstring{
private :
char * data;
public :
Cstring(const char * str =NULL);
Cstring(const Cstring &another);
~Cstring();
Cstring & ope...
分类:
其他好文 时间:
2014-08-08 18:13:16
阅读次数:
181
#include
#include
int main()
{
CString strCString = "iloveyou";
std::string strString = CT2A(strCString);
return 0;
}...
分类:
其他好文 时间:
2014-08-07 00:53:48
阅读次数:
213
先 转载一段别人的文章CString类的这几个函数, 一直在用, 但总感觉理解的不够透彻, 不时还有用错的现象. 今天抽时间和Nico一起分析了一下, 算是拨开了云雾:GetBuffer和ReleaseBuffer是一套需要配合使用的函数, 与GetBufferSetLength相比, 优点是如果分...
分类:
其他好文 时间:
2014-08-05 18:22:39
阅读次数:
188
一.函数原型CString::GetBufferLPTSTR GetBuffer( int nMinBufLength );throw( CMemoryException );Return ValueAn LPTSTR pointer to the object’s (null-terminated...
分类:
其他好文 时间:
2014-08-05 10:56:49
阅读次数:
366
在windows编程中,由于编码方式的不同和c与c++的不同而造成了许多复杂的有关字符串之间的转换首先,windows编码方式有ANSCLL和UNICODE,前者是单字符的,后者是双字符的。然后,char*理所当然是单字符的,string也是单字符的,而CString是Tchar的。那么什么是TCH...
分类:
编程语言 时间:
2014-08-05 10:44:39
阅读次数:
259
CString strScale;
strScale.Format(_T("1:%d"),m_pBlock->GetBlkScale());
int iIndex=strTitle.ReverseFind(_T('|'));
if(iIndex> -1)
{
CString str1,str2;
str1=strTitle.Mid(0,iIndex);
str1 = L"1/...
分类:
其他好文 时间:
2014-08-04 17:38:27
阅读次数:
159
??
1.编写头文件
#define
_CRT_SECURE_NO_WARNINGS
//#pragmawarning(disable:4996)
#include
#include
#include
struct
CString
{
char *p;
//保存字符串首地址
i...
分类:
编程语言 时间:
2014-08-03 23:27:26
阅读次数:
557
超时递推实现 f[i][j]表示前i个数能够表示j状态的方案数,其中j为最多20位的二进制,表示前i个数的和(1-20)是否达到#include "cstdio"#include "cstring"#define min(x,y) (x>y?y:x)#define MOD 1000000007int...
分类:
其他好文 时间:
2014-08-02 18:18:03
阅读次数:
257
头文件:Cstring trim(char ch = ' ');std::vector split(const Cstring & strSep,bool needTrim = true);cpp 文件:Cstring Cstring::trim(char ch){ TrimLeft(ch); Tr...
分类:
其他好文 时间:
2014-07-31 19:59:27
阅读次数:
219
1. c++中string到int的转换1) 在C标准库里面,使用atoi:#include #include std::string text = "152"; int number = std::atoi( text.c_str() ); if (errno == ERANGE) //可能是s....
分类:
编程语言 时间:
2014-07-31 19:48:27
阅读次数:
294