网志档案列表:4 / 2006

More Effective C++ 25: Virtualize constructors and non-member functions @ 4/27/2006

Though constructors and non-member functions can't be declared virtual, we can make them behave virtually. Consider three cla...
发布于 4/27/2006 11:07:22 | 评论:0

More Effective C++ 24: Understand the costs of virtual functions, multiple inheritance... @ 4/26/2006

Virtual functions are generally implemented by using [i]virtual tables[/i] and [i]virtual table pointers[/i], which are called v...
发布于 4/26/2006 13:45:59 | 评论:0

More Effective C++ 23: Consider alternative libraries @ 4/25/2006

Different libraries offer different performance, so when you have decided that one library is becoming the bottleneck of your pr...
发布于 4/25/2006 21:46:13 | 评论:0

More Effective C++ 22: Consider using op= instead of stand-alone op @ 4/24/2006

The operator += is usually more efficient than + because operator + always returns a new object while += doesn't. For efficienc...
发布于 4/24/2006 13:33:07 | 评论:0

You Raise Me Up @ 4/22/2006

When I am down and all my soul so weary When troubles come and my heart burdened be Then, I am still and waiting in the silenc...
发布于 4/22/2006 13:29:54 | 评论:0

More Effective C++ 21: Overload to avoid implicit type conversions @ 4/22/2006

[code] class UPInt { // class for unlimited public: // p...
发布于 4/22/2006 10:57:43 | 评论:0

More Effective C++ 20: Facilitate the return value optimization @ 4/21/2006

Returning objects by value is always costy, but you can minimize the cost using return value optimization. [code] class Ration...
发布于 4/21/2006 13:24:51 | 评论:0

More Effecitve C++ 19: Understand origin of temporary objects @ 4/19/2006

Temporary objects are generated when: 1. implicit type conversions are applied to make function calls succeed 2. functions ret...
发布于 4/19/2006 14:15:06 | 评论:0

More Effecitve C++ 18: Amortize the cost of expected computation @ 4/18/2006

We disscussed lazy evaluation in the last Item, now we are disscussion over-eager evaluation. Lazy evaluation is used to data t...
发布于 4/18/2006 12:39:57 | 评论:0

More Effective C++ 17: Consider using lazy evaluation @ 4/17/2006

Lazy evaluation sometimes saves resources, and it is applicable in a lot of areas. Here's three of them: 1. Reference Countin...
发布于 4/17/2006 9:59:25 | 评论:0

又见下沙 @ 4/17/2006

今天早上起来,外面一片土黄,知道是又下沙了 庆幸自己昨晚没有开窗,否则今天早上就要被沙子埋了。 自从上次在北信看到一次下沙,已经有两三年了吧。北京一直想治理,可是一直收效甚微。大自然这东西,哪里是渺小的人类可以践踏的呢。砍树的时候怎么就没想过会有今天的...
发布于 4/17/2006 9:46:58 | 评论:1

More Effective C++ 16: Remember the 80-20 rule @ 4/16/2006

The 80-20 rule states that 80 percent of a program's resources are used by 20 percent of the code. So when tuning the performan...
发布于 4/16/2006 19:07:37 | 评论:0

More Effective C++ 15: Understand the costs of exception handling @ 4/15/2006

Exception handling requires a lot of bookkeeping. At each point during execution, programs must keep record of the objects that ...
发布于 4/15/2006 11:37:54 | 评论:0

More Effective C++ 14: Use exception specifications judiciously @ 4/14/2006

What is "exception specification?" [code] void newObject() throw(bad_alloc); // exception specifcation [/code] This excep...
发布于 4/14/2006 13:38:35 | 评论:0

More Effective C++ 13: Catch exceptions by reference @ 4/13/2006

You can catch exceptions by pointer, by value or by reference. 1. Catching exceptions by pointer leaves us with the question ...
发布于 4/13/2006 14:24:39 | 评论:0

More Effective C++ 12: Understand how throwing an exception differs from passing a parameter or ... @ 4/12/2006

Understand how throwing an exception differs form passing a parameter or calling a virtual function. There are three major di...
发布于 4/12/2006 17:20:08 | 评论:0

More Effective C++ 11: Prevent exceptions from leaving destructors @ 4/11/2006

Destructors are called in two situations, normal and abnormal. The [i]normal[/i] situation is when an object goes out of scope, ...
发布于 4/11/2006 13:17:39 | 评论:0

Effective C++ 10: Prevent resource leaks in constructors @ 4/10/2006

[code] class lock{ public: lock(const char * key1,const char * key2){ if(key1!=NULL) theKey1=new ke...
发布于 4/10/2006 14:53:35 | 评论:0

去桃源仙谷玩,累死了 @ 4/10/2006

上星期六星期天实验室组织春游,去桃源仙谷,老板给报销。 星期六四点出发,去清华园火车站坐火车(汗……以前都没听说过这里还有火车站)。到火车站一看,全是出去春游的学生,大约有100多号人,结果火车就挤得要死。 7点多到农家,天已经黑了,随便吃了点...
发布于 4/10/2006 14:03:36 | 评论:1

More Effective C++ 9: Use destructors to prevent resource leaks @ 4/7/2006

Exception handling makes us as much trouble as they solve. [code] string * a=new string; try{ ifstream file("kk.txt"); ...
发布于 4/7/2006 14:00:50 | 评论:0

More Effective C++ 8: Understand different meanings of new and delete @ 4/6/2006

There are[i] new operator[/i], [i]operator new [/i]and [i]placement new[/i]. [b]new operator[/b] [code]string * ps=new strin...
发布于 4/6/2006 11:30:11 | 评论:0

More Effective C++ 7: Never overload && || or , @ 4/4/2006

The operators && || and , always evaluate their parameters from left to right. [code]if(p!=NULL && p.size()!=0){...}[/code] ...
发布于 4/4/2006 14:16:00 | 评论:1