TITLE: aggregates, PODs, and constructors (Newsgroup: comp.std.c++, 3 Feb 99) ELLIS: sellis@geocities.com (Sean Ellis) >I've had a poke around in the FAQ, and used Deja news to go through a >bunch of old posts, and I haven't found the answer to this question >anywhere: > >* Why are constructors prohibited on aggregate types > (and therefore on POD types)? CLAMAGE: Steve Clamage, stephen.clamage@sun.com You've got it backwards. If a type has a user-defined constructor or destructor, it is not an aggregate, by definition. The term aggregate is defined in order specify certain kinds of C compatibility. The term POD ("Plain Old Data") is defined in order to specify stricter kinds of C compatibility. An aggregate is a type that has properties that allow certain operations to proceed exactly as they do in C. In particular, you can use brace-initialization. But if a class has a user-defined constructor, it must be assumed that the constructor is necessary for initialization, and the compiler cannot just assign values to data members. Once you reach that point, the brace-initialization rules break down. In simple cases they might still apply, but in typical cases the brace-initialization rules don't work. Since we are concerned only about C compatibility for aggregates and PODs, we allow only those C++ features that have no interaction with C semantics. Constructors don't pass that test.