- 博客(4)
- 收藏
- 关注
原创 Effective STL: Item 21: Always have comparison functions return
Let me show you something kind of cool. Create a set where less_equalis the comparison type, then insert 10 into the set:set > s; // s is sorted by “s.insert(10); // insert the value 10Now try inserti
2001-06-06 22:07:00
788
1
原创 Effective STL:Item 16: Know how to pass vector and string data to
Since C++was standardized in 1998,the C++elite haven¡¯tbeenterri-blysubtle in their attempt to nudge programmers away from arraysand towards vectors. They¡¯ve been similarly overt in trying to get de
2001-06-06 22:05:00
976
原创 Effective STL: Item 2: Beware the illusion of container-independent
The STL is based on generalization. Arrays are generalized into con-tainersand parameterized on the types of objects they contain. Func-tionsare generalized into algorithms and parameterized on th
2001-06-06 09:06:00
849
原创 条款14 基类的析构函数一定要定义为虚拟函数(From Effective C++)
有时一个类需要知道当前有多少个该类的对象,达到这个目的最直接的方式是定义一个用于统计对象个数的静态成员变量。该变量被初始化为0,调用类构造函数时增加1,调用析构函数时减少1。假设你正在编写一个军用程序,其中一个表示敌军目标的类定义如下:class EnemyTarget {public: EnemyTarget() { ++numTargets; } EnemyTarget(con
2001-06-05 20:26:00
1544
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人