一些惯用的编码手法
来源:互联网 发布:汽车保养提醒软件 编辑:程序博客网 时间:2024/05/01 22:26
定义显示的宏的来完成一些显示的常规的动作。
定义枚举来做显示分类示例说明。
类函数直接返回它的枚举值。
怎样写一个单例模式。
怎样默认产生类默认生成的函数。
赋值兼容规则:
类对象,类引用,类指针和类的
函数指针的声明和使用
typedef TDataWrapper* (*CRT_DB_PTR)(void);
用结构体来封装函数指针或者一些常用的东西
struct TCmdFactory
{
CRT_CMD_REQ_PTR pCmdReq;
CRT_ACT_PTR pAction;
CRT_DB_PTR pDataWrapper;
TCmdFactory(){
pCmdReq = NULL;
pAction = NULL;
pDataWrapper = NULL;
};
};
typedef 的使用
typedef TLibMsg* PTSmfMsg;
stl 模板数据类型的重复使用 。一个模板作为另一个模板的元素使用。复合构造stl模板数据类型。
把多个数据集类放在一个类中来使用。全当是做数据的封装。
指针的使用最多三级。指针成员指导使用最多也是三级。
函数指针的定义 typedef string (*FUNC_BUILD_UID)();
新写法:
string intToStr(int iSource)
{
#ifdef WIN32 //在函数中通过判断
_snprintf(chBuff, MAX_INT_LEN, "%d", iSource);
#else
snprintf(chBuff, MAX_INT_LEN, "%d", iSource);
#endif
}
clone 一个数据怎么写 怎么写一个clone 函数
void TAppEirImeiData::clone(const TAppEirImeiData &srcData)
{
}
一个数据:
typedef TXmlLib* (*CRT_XML_LIB_PTR)(void);
extern map<string, CRT_XML_LIB_PTR> g_mapXMLLibFactory;
向量函数指针:
指针向量做函数参数
void TDataItem::setValue(const vector<TAppData*> &vecValue)
{
m_vecData = vecValue;
}
返回一个函数指针向量
vector<TDataItem*> TDataTeam::getValue()
{
return m_vecData;
}
结构体的定义:
typedef struct struct_name{}new_structName; 结构体和枚举都可以
stl的使用
DLL_EXP int gu_make_mml_func_callback_3(std::vector<NewService_Mapping*> & newservice,
std::vector<string>& mmlList);
DLL_EXP void LibRegBuildUID(FUNC_BUILD_UID pFunc); FUNC_BUILD_UID函数指针是一种类型
将new和delete定义成宏的形式。避免野指针的形成。
怎样定义一堆的宏,然后让一堆的宏去定义结构体。
return *this; //返回this指针对象的值也就是是一个对象
//判断两个对象的值是否相等
if (this == &rhs)
{
return *this;
}
函数指针定义全局变量。(函数指针是一个类型)
FUNC_AddFSMType g_funcAddFsmType = NULL;
const面表示该函数const函数即函数会修改类数据成员前面const 表示返回值const类型当返回引用时想该引用被作左值时应该用const前面修饰
奇葩的类
class SQLAPI_API SAValue : public SAValueRead
{
friend class ISACursor;
friend class IibCursor;
friend class IssDBLibCursor;
friend class Iora7Cursor;
friend class Iora8Cursor;
friend class IoraCursor;
friend class IsbCursor;
friend class IodbcCursor;
friend class Idb2Cursor;
friend class IinfCursor;
friend class IsybCursor;
friend class ImyCursor;
friend class IpgCursor;
// ***BEGIN*** 2003-07-07 by ZhangZongchu added SQLAPIV100R002.4 D26481
friend class SACommand;
// ***END*** 2003-07-07 by ZhangZongchu added SQLAPIV100R002.4 D26481
private:
bool m_bInternalUseDefault;
- 一些惯用的编码手法
- 程序设计的惯用手法
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 旧话重提:pImpl惯用手法的背后
- 大内高手—惯用手法
- 大内高手—惯用手法
- 大内高手—惯用手法
- 大内高手—惯用手法
- 内存研究系列 - 惯用手法
- 大内高手—惯用手法
- 大内高手—惯用手法
- 大内高手—惯用手法
- IOS文件路径处理方法
- MySQL命令随记
- imx6 串口配置
- Hadoop
- 《Android开发自我整理知识——简介及学习资料链接》
- 一些惯用的编码手法
- jquery 设置checkbox全选 全不选
- 【c++强制类型转换】:dynamic_cast、const_cast 、static_cast、reinterpret_cast
- 流状态的查询和控制
- 详解realloc函数的功能——C语言代码展示
- 第九周项目2
- maven findbugs插件集成
- EditText控件中的inputType的属性值详情
- 2011年华为编程大赛B卷第二道题