摘要: 条款005:了解C++默默编写并调用哪些函数如果有引用或者const成员变量,编译器拒绝合成赋值操作符。template <typename T>class NameObject{public: NameObject(string& name,const T& value): nameValue(name),objectValue(value) { }private: string& nameValue;//&引用变量 const T objectValue;};//warning C4512: 'NameObject<T> 阅读全文
posted @ 2013-02-22 15:43 浑身胆满脸魄 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 导读Pass-by-value意味着调用copy构造函数。尽可能避开undefined behavior。条款01:视c++为一个语言联邦。四个次语言,C、OO、template、STL。每个次语言都有自己的规约。当从一个次语言切换到另一个次语言时,高效编程的守则要求你改变策略…用哪种策略?取决于你使用C++的哪一个部分。条款002:尽量以const enum inline 替换#define#define不提供任何封装性。#define到#undef之间均可见。#define有可能被编译器忽视,没进入symbol table。const double AspectRatio = 1.653; 阅读全文
posted @ 2013-02-22 14:41 浑身胆满脸魄 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 53*不要轻忽编译器的警告Pay attention to compiler warnings.54*让自己熟悉包括TR1在内的标准程序库Familiarize yourself with the standard library,including TR1.C++98的内容:STL(Standard Template Library,标准模板库):容器、迭代器、算法、函数对象、容器适配器、函数对象适配器。Iostreams:用户自定缓冲功能(毛?),国际化I/O(毛?iostream等类?),对象:cin,cout,cerr,clog。国际化支持:wchar_t和wstring。——> 阅读全文
posted @ 2013-02-22 10:25 浑身胆满脸魄 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 手工管理内存 heap资源软件使用内存的行为特征---手动定/修改分配和归还内存的工作。C++内存管理例程的行为?operator new, operator delete, +new-handler, operator new[], operator delete[]注:不负责STL容器的HEAP管理多线程环境下的内存管理?heap——可被改动的全局性资源。race condition(竞速状态)出现 大家都同时访问一个资源,只拼速度,不稳定。可改动的static数据。thread-aware(线程感知)程序员 同步控制(synchronization),无锁算法 ,精心防止并发访问(con 阅读全文
posted @ 2013-02-21 13:36 浑身胆满脸魄 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 41*了解隐式接口和编译期多态implicit interface, complie-time polymorphism/*7 模板与泛型编程template & Generic programming所写代码和其所处理的对象类型彼此独立模板 元编程template metaprogramming*//*41隐式接口 implicit interface编译期多态 complie-time polymorphism*///widget.h#include <iostream>class Widget{public: Widget(); virtual ~Widget(); 阅读全文
posted @ 2013-02-20 15:49 浑身胆满脸魄 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 以下std::tr1::bind(&GameLevel::health, currLevel, _1) 报错error C2065: '_1' : undeclared identifier原因见MSDN\Standard C++ Library TR1 Extensions Reference\<functional> (TR1)Object_1 ObjectDescription Placeholders for replaceable arguments.namespace ... 阅读全文
posted @ 2013-01-22 14:08 浑身胆满脸魄 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 如何让两个安装程序(setup.exe),共享同一个component? 要实现的效果是,两个程序共享同一个dll,当两个程序中有一个被卸载掉时,这个dll仍存在,不随着第一个卸载而从系统中删除,因为另一个程序还要用它嘛。而当两个程序都被卸载时,这个dll被卸载掉。 原谅我几乎用了8个多小时才搞明白...痛苦地搜索和阅读过程就不赘述了,总之在帮助里找到一条靠谱的信息,帮助里的索引是Refcounting Shared Files内容如下Windows Installer has a built-in mechanism for installing shared files. If the.. 阅读全文
posted @ 2013-01-22 14:00 浑身胆满脸魄 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 在本机上成功编译运行的setup.exe,换到一个另一个机器上运行setup.exe时弹出“内部错误2235,Runtimeflags, select 'component','RuntimeFlags','Keypath','Attributes' from 'component' where 'component'=?”提示框。无法运行。 在英文的论坛上(谷歌出来的)有人如是说: You can get this if there are no components or features in 阅读全文
posted @ 2013-01-22 13:50 浑身胆满脸魄 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 目的一些文件,在安装过程中使用,在安装结束后从目标机器上删除。那么这些文件应该放在安装工程的哪里呢?分析以licence.txt(安装过程中常见的版权声明之类)为例寻求,因为这个文件亦是只在安装过程中需要的,安装过程结束后删掉。★帮助SUPPROTDIR中的说明SUPPORTDIRDuring setup initialization, InstallShield Developer locates a folder on the target system into which it can copy temporary files and files that were compresse 阅读全文
posted @ 2013-01-22 13:39 浑身胆满脸魄 阅读(957) 评论(1) 推荐(0) 编辑
摘要: 1、使用std命名空间中的东西,需要#include <iostream>,还有一个可疑的<iostream.h>是什么呢? <iostream.h>是为了兼容以前的C++代码,相当于在C中调用库函数,使用全局namespace,不加using namespace std那句也识别std中的名称。<iostream>是为了支持新的标准,新标准规定C++头文件不加.h。<iostream>中没有定义全局命名空间,必须using std;这样才能正确使用C++标准程序库中的所有标识符。2、关于命名空间using namespace std 阅读全文
posted @ 2013-01-22 13:14 浑身胆满脸魄 阅读(244) 评论(0) 推荐(0) 编辑