More Effective C++ Tips
Programming ....
|
|
|
|

Basics.
– Distinguish Between Pointers and References.
– Prefer C++Style Casts.
– Never Treat Arrays Polymorphically.
– Avoid Gratuitous Default Constructors.
Operators.
– Be Wary of User Defined Conversion Functions.
– Distinguish Between Prefix and Postfix Forms of Increment and decrement operators.
– Never Overload &&, ||, or,.
– Understand the Different Meanings of New and Delete.
Exceptions.
– Use Destructors to Prevent Resource Leaks.
– Prevent Resource Leaks in Constructors.
– Prevent Exceptions from Leaving Destructors.
– Understand How Throwing an Exception Differs from Passing a Parameter or Calling a Virtual Function.
– Catch Exceptions by Reference.
– Use Exception Specifications Judiciously.
– Understand the Costs of Exception Handling.
Efficiency.
– Remember the 8020 Rule.
– Consider Using Lazy Evaluation.
– Amortize the Cost of Expected Computations.
– Understand the Origin of Temporary Objects.
– Facilitate the Return Value Optimization.
– Overload to Avoid Implicit Type Conversions.
– Consider Using Op= Instead of Stand Alone Op.
– Consider Alternative Libraries.
– Understand the Costs of Virtual Functions, Multiple Inheritance, Virtual Base Classes, and RTTI.
Techniques.
– Virtualizing Constructors and NonMember Functions.
– Limiting the Number of Objects of a Class.
– Requiring or Prohibiting HeapBased Objects.
– Smart Pointers.
– Reference Counting.
– Proxy Classes.
– Making Functions Virtual With Respect to More Than One Object.
Miscellany.
– Program in the Future Tense.
– Make NonLeaf Classes Abstract.
– Understand How to Combine C++ and C in the Same Program.
– Familiarize Yourself With the Language Standards

Prashant Mhatre
Make Money, Programming, Bollywood, Marathi
^_*