Internal typedefs in C++ - good style or bad style?

前端 未结 9 1425
天涯浪人
天涯浪人 2020-12-07 07:28

Something I have found myself doing often lately is declaring typedefs relevant to a particular class inside that class, i.e.

class Lorem
{
    typedef boost         


        
9条回答
  •  执笔经年
    2020-12-07 08:01

    I recommend to move those typedefs outside the class. This way, you remove direct dependency on shared pointer and vector classes and you can include them only when needed. Unless you are using those types in your class implementation, I consider they shouldn't be inner typedefs.

    The reasons you like it are still matched, since they are solved by the type aliasing through typedef, not by declaring them inside your class.

提交回复
热议问题