Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
c++0x pods and constructors
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="James Kanze, post: 3967536"] The rationale is probably simply that they needed the distinction for some reason. In C++03, the distinction is clear: aggregates can only be initialized using the aggregate initialization syntax; other things can't be initialized using the aggregate initialized syntax. In C++0x, there will be a universal initialization syntax, which works for both aggregates and non aggregates, but the semantics are still different: when initializing an aggregate, you specify the initializer for each member; when initializing a non-aggregate, you specify the arguments for a constructor. Intuitively: an aggregate is determined superficially: an array or a class with no user defined constructor, but elements of the array or class aren't necessarily aggregates. A POD is defined "deeply": for something to be a POD, all of its elements must be POD's, recursively. There's more to it than that, of course. The important difference is that whether something is an aggregate or not determines how it is initialized (in C++03) or what the initialization arguments mean (in C++0x). The difference between a POD and a non-POD is that a POD has constructors and destructors which are effectively no-ops, and an assignment operator which is the equivalent of memcpy; this plays a role in various contexts. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
c++0x pods and constructors
Top