1

In https://stackoverflow.com/a/15483397/368896, the poster indicates - if I'm reading it correctly - that at least one data member must be present in order for a class not to be a POD.

class X {};        // This class is a POD
class Y { int y; } // This class is not, because of the presence of the data member

Why does there need to be at least 1 data member in order for a class to NOT be a POD?

Community
  • 1
  • 1
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
  • possible duplicate of [What are Aggregates and PODs and how/why are they special?](http://stackoverflow.com/questions/4178175/what-are-aggregates-and-pods-and-how-why-are-they-special) – Nicol Bolas Mar 18 '13 at 23:41
  • 2
    It is the presence of a *private* non-static data member that makes is a non-POD. If `Y::y` were public, `Y` would be POD. – juanchopanza Mar 18 '13 at 23:49
  • 1
    Actually, I believe what I said in my first comment applies to C++03. `Y` is a POD in C++11. – juanchopanza Mar 18 '13 at 23:58
  • @juanchopanza Do you know what, then, in the linked posting, makes it a non-POD? Thanks. – Dan Nissenbaum Mar 18 '13 at 23:59
  • 2
    Well, what I can see is a `struct A` with a public data member and a private one. In C++03, all data members must be public. In C++11, they must all have the same access. So `A` is not a POD in either standard. – juanchopanza Mar 19 '13 at 00:03

0 Answers0