摘要:在c++中,有2种class data member:static和nostatic,以及3钟class member function:static,nostatic和virtual。已知下面这个class Point声明:class Point{public: Point(float xv... 阅读全文
《More Effective C++》 条款5 谨慎定义类型转换函数
2014-05-10 23:48 by youxin, 337 阅读, 0 推荐, 收藏,
摘要:---恢复内容开始---C++编译器能够在两种数据类型之间进行隐式转换(implicit conversions),它继承了C语言的转换方法,例如允许把char隐式转换为int和从short隐式转换为double。因此当你把一个short值传递给准备接受double参数值的函数时,依然可以成功运行。... 阅读全文
《Effective C++》条款26 防卫潜伏的ambiguity模棱两可的状态
2014-05-10 23:17 by youxin, 290 阅读, 0 推荐, 收藏,
摘要:每个人都有思想。有些人相信自由经济学,有些人相信来生。有些人甚至相信COBOL是一种真正的程序设计语言。C++也有一种思想:它认为潜在的二义性不是一种错误。ambiguity这是潜在二义性的一个例子:class B; // 对类B提前声明 // ... 阅读全文
《Effective C++》条款14 总是让base class拥有virtual destructor
2014-05-10 22:25 by youxin, 400 阅读, 0 推荐, 收藏,
摘要:有时,一个类想跟踪它有多少个对象存在。一个简单的方法是创建一个静态类成员来统计对象的个数。这个成员被初始化为0,在构造函数里加1,析构函数里减1。(条款m26里说明了如何把这种方法封装起来以便很容易地添加到任何类中,“my article on counting objects”提供了对这个技术的另... 阅读全文
《Effective C++》内存管理
2014-05-09 16:30 by youxin, 390 阅读, 0 推荐, 收藏,
摘要:如果global new-hander没有成功配置,会抛出一个std::bad_alloc的exception。#include#include#includeusing namespace std;templateclass NewHandlerSupport{public: static ... 阅读全文
c++类型转换Type Cast)
2014-05-09 00:53 by youxin, 1476 阅读, 0 推荐, 收藏,
摘要:C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是:TYPE b = (TYPE)a。C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用。const_cast,字面上理解就是去const或volatile属性。static_cast,命名上理解是静态类型转换。如... 阅读全文
C++中的new/delete与operator new/operator delete
2014-04-27 18:01 by youxin, 376 阅读, 0 推荐, 收藏,
摘要:new operator/delete operator就是new和delete操作符,而operator new/operator delete是函数。 new operator(1)调用operator new分配足够的空间,并调用相关对象的构造函数(2)不可以被重载 operator new( 阅读全文
Buddy system伙伴分配器实现
2014-04-27 16:42 by youxin, 3963 阅读, 0 推荐, 收藏,
摘要:wikipedia:http://en.wikipedia.org/wiki/Buddy_memory_allocationThebuddy memory allocationtechnique is amemory allocationalgorithm that divides memory i... 阅读全文
Linux iconv使用
2014-04-27 13:00 by youxin, 1614 阅读, 0 推荐, 收藏,
摘要:iconv [选项】文件输入/输出格式规范:-f, --from-code=名称 原始文本编码-t, --to-code=名称 输出编码信息:-l, --list 列举所有已知的字符集输出控制:-c 从输出中忽略无效的字符-o, --output=FILE 输出文件-s, --silent 关闭警告... 阅读全文
内存管理(memory allocation内存分配)
2014-04-27 03:01 by youxin, 2943 阅读, 0 推荐, 收藏,
摘要:Memory managementis the act of managingcomputer memory. The essential requirement of memory management is to provide ways to dynamically allocate port... 阅读全文
浙公网安备 33010602011771号