const成员不能改变其所操作的对象的数据成员。const必须同时出现在声明和定义中。若只出现在其中一处,就会出现一个编译错误。
数组在概念上类似于vector,但既不是抽象的,也不是封装的。可以通过访问存放数组的内存来直接操作数组。
static成员函数没有this形参,它可以直接访问所属类的static成员,但不能直接使用非static成员。
CMainFrame *m_pMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
string 关键字使用时需要包含以下头文件
#include <string.h>
#include <iostream>
using namespace std;
这里包含iostream.h是不能识别string关键字的
CString 类与String关键字不同,这是需要注意的,同样,CString需要包含的头文件是#include <afx.h>
vetor删除元素,容易导致迭代器失效
RELATION_VECTOR::iterator iter;
for (iter = m_RelationList.begin(); iter!=m_RelationList.end(); )
{
if (strcmp((*iter)->sSltName,lpctSltName)==0)
{
m_RelationList.erase(iter);
}
else
++iter;
}
}
typedef char TCHAR;
std::string 相当于char *
typedef const TCHAR *LPCTSTR;
CTime tmSCan = CTime::GetCurrentTime();
CString szTime = tmScan.Format("'%Y-%m-%d %H:%M:%S'");
这样得到的日期时间字符串就是以"2006-11-27 23:30:59"的格式.这是不是很方便呢?
//取得CTime中的日期
CString cstrDate = tmScan.Format("%Y-%m-%d");
//取得CTime中的时间
CString cstrTime = tmScan.Format("%H:%M-%S");
/r就是换行
/n是回车,
win 用 /r/n
linux/unix 用 /n
Mac OS 用 /r
CBStatic32
//declare
TCHAR tstrCurrentPath[MAX_PATH];
//initialize
memset(tstrCurrentPath, 0, MAX_PATH);
//Get
GetCurrentDirectory(MAX_PATH, tstrCurrentPath);
//Output
wcout << tstrCurrentPath << endl;
TCHAR exeFullPath[MAX_PATH];
GetModuleFileName(NULL,exeFullPath,MAX_PATH); // EXE 文件名
*_tcsrchr(exeFullPath,'//') = 0; // 去掉文件名
CString strExePath = exeFullPath; // EXE 所在的路径
*_tcsrchr(exeFullPath,'//') = 0; // 再去掉一段
CString strParentPath = exeFullPath; // EXE 所在的路径的父文件夹
TRUE : int
true ;bool
class Empty
{
public:
Empty(); // 缺省构造函数
Empty( const Empty& ); // 拷贝构造函数
~Empty(); // 析构函数
Empty& operator=( const Empty& ); // 赋值运算符
Empty* operator&(); // 取址运算符
const Empty* operator&() const; // 取址运算符 const
};
_T的意思?
判断文件是否存在,并删除
CFileStatus status;
if (CFile::GetStatus(fileName,status)==TRUE)
{
CFile::Remove(fileName);
}