Monday, December 24, 2007

c++ abstract

1. system function

2. the use of namespace to distinguish

3. the order of linking; linker links object module (corresponding to file) and the order may be fixed

4. extern (declaration rather than definition)

5. oct hex used for output with different numeric formats

6. the C++ Standard does not “include” the STL (HP and then SGI)

7.
The boundary between compilers and interpreters can with Python, which has many of the features and power of a compiled language but the quick of an interpreted language.

8. volatile versus const; volatile means
“You never know when this will change,” and prevents the compiler from performing any optimizations based on the stability of that variable.

Tuesday, December 11, 2007

excerpt of effective c++

1. rules for effective c++ programming vary, depending on the part of c++ you are using (c, c++, template, STL)

2. For simple constants prefer const objcts or enums to $defines (enum hack)

3. For function-like macros, prefer inline functions to #defines (which has side-effect)

4. Declaring soemthing const helps compilers detect usage erros. const can be applied to objects at any scope, to function parameters and return types, and to member functions as a whole

5. Compilers enforce bitwise constness, but you should program using conceptual constness (e.g., use of mutable)

6. When const and non-const member functions have essentially identical implementations, code duplication can be avoided by having the non-const version call the const version

7. Manually initialize objects of built-in type, because C++ only sometimes initializes them itself

8. In a constructor, prefer use of the member initialization list to assignment inside the body of constructor. List data members in the initialization list in the same order they are declared in the class.

9. Avoid initilization order problems across translation units by replacing non-local static objects with local static objects