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++
Default ctor, etc generated by compiler for structs?
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: 2936442"] No. I suspected that what you were actually talking about were POD's, but I wanted to make it clear. C++ doesn't really have "struct"'s, just classes, but it does distinguish between POD's and other types. And if your problem is interfacing with a C API, a POD struct is really what you need; it's the equivalent of a C struct. [...] I thought someone had already posted it, but from the standard: §3.9 paragraph 11: Arithmetic types (3.9.1), enumeration types, pointer types, and pointer to member types (3.9.2), and cv-qualified versions of these types (3.9.3) are collectively called scalar types. Scalar types, POD-struct types, POD-union types (clause 9), arrays of such types and cv-qualified versions of these types (3.9.3) are collectively called POD types. §9 paragraph 4: A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. Similarly, a POD-union is an aggregate union that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-declared copy assignment operator and no user-declared destructor. A POD class is a class that is either a POD-struct or a POD-union. And finally, §8.5.1 paragraph 1: 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). (This is from N2134, the version of the draft that I happen to have on line here. I think that there's some open work still in progress here, because in theory, at least, a compiler is not required to maintain order when there is an intervening access specifier, even when it doesn't change access. So---again in theory---given: class C { public: int x ; public: int y ; public: int x ; } ; the compiler is allowed to put x, y and z in any order, even though this is---according to the rules above---a POD struct.) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Default ctor, etc generated by compiler for structs?
Top