Can a class with all private members be a POD class?

前端 未结 3 1942
执念已碎
执念已碎 2021-01-18 03:41

I\'ve heard before that POD types cannot have private data -- but according to the C++0x draft I have the requirement is looser (emphasis mine):

has t

3条回答
  •  情歌与酒
    2021-01-18 04:21

    C++03 still does not allow non-static private or protected data in POD classes. This requirement is specified in the definition of aggregate

    An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).

    and POD class must be an aggregate first.

提交回复
热议问题