effective C++ 学习(Miscellany)

来源:互联网 发布:圆梦会计软件联系方式 编辑:程序博客网 时间:2024/06/05 09:02

Miscellany

Item 53: Pay attention to compiler warnings.

1.     Sometimes warnings can exposeyour faults.

class B

{

public:

   virtual void f() const;

};

class D: public B

{

public:

   virtual void f();

};

Warning:D::f() hides virtual B::f()

Note: const is also the part of functionsign, so the f() in derived class D don’t redeclare f() in base class B.

Item 54: Familiarize yourself with the standard library,including TR1.

1.     The tr1::weak_ptrs can solvethe problem of cycle of the tr1::shared_ptr;

2.     The tr1::function is discussedin item 35;

The tr1::bind can make it achievedthat when a function is called, the bound objects is also called, which canreplace the pointer “this” in the member function.

3.     Hash tables are used to achievesets, multisets, maps and multi-maps;

4.     Regular expressions(正则表达式);

5.     Tuples (变量组),tr1::tuple can contain any numberof objects;

6.     The tr1::array is an array withthe style of STL, but its size is constant;

7.     The tr1::mem_fn is used toconstruct member function pointers;

8.     The tr1::reference_wrappermakes containers like contain references;

9.     Random number;

10.  Special math function, including Laguerre polynomial、Bessel functions、completeelliptic integrals;

11.  C99 Compatible extensions;

12.  Type traits, it provides types information during compiling,including judging whether the T is built-in types or not, whether to providevirtual functions, whether it is an empty class, whether it can be convertedinto other types;

13.  The tr1::result_of return the “return type” of function;

Item 55: Familiarize yourself with Boost.

1.     String and text processing;

2.     Containers;

3.     Function objects and seniorprogramming;

4.     Generic programming;

5.     Template metaprogramming, whichcan provide compile-time entities, like types list.

6.     Math and numerics;

7.     Correctness and testing;

8.     Data structure; type-safeunions and tuple;

9.     Inter-language support, allow seamlessinteroperability of C++ and python;

10. Memory; Pool and smartpointers.

11. CRC detection, date and timeprocessing, removing in file system;