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++
Why can't PODs have 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="JohnQ, post: 2988067"] Why the virtual inheritance? Defining all the default args will lead to ambiguity errors being produced by the compiler. Ooo, that destructor doesn't look good at all there the way you defined it. (Wouldn't be allowed in a POD either). You were _trying_ to define a conversion operator, but you don't have to because MyRect IS a RECT. If you were to embed the RECT into MyRect instead of derive from it, then you'd need a conversion operator. Currently I'm doing the derivation from RECT rather than composition (embedding) with RECT, but it escapes me why I decided that in this case derivation was better than composition (probably so I don't have to provide accessor functions and the conversion operator).. That's kind of what I've been doing to get compatibility of MyRect and RECT (I do something a little different, but for practical discussion, it suffices to say that). But it doesn't solve the problem since you can't create an array of MyRects and get the desired layout (a contiguous array of 16-byte RECT-like things). It should be possible to define a MyRect so that it is 16-bytes and still allows initializing constructors. Well consider that you might want to construct a MyRect with 2 MyPoint objects: MyRect(MyPoint& origin, MyPoint& extent); MyRect will (again/still) not FORMALLY be a POD if you define the above constructor. John [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Why can't PODs have constructors?
Top