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="BobR, post: 2988883"] Oops. I was cleaning out my 'TestBench' program, and removed the wrong code (had about 5 versions). Here is the one I meant to post: struct Rect : RECT{ Rect( long x1 = 0, long y1 = 0, long x2 = 10, long y2 = 10 ){ left = x1; bottom = y1; right = x2; top = y2;} }; { // main() or ? using std::cout // for NG post Rect rect( 10, 12, 22, 42 ); RECT rect1( rect ); RECT rect1a( Rect( 7, 14, 27, 34 ) ); Rect rect2; cout<<" Rect rect.bottom="<< rect.bottom <<'\n' <<" RECT rect1.bottom="<< rect1.bottom <<'\n' <<" RECT rect1a.bottom="<< rect1a.bottom <<'\n' <<" Rect rect2.top="<< rect2.top <<'\n' <<" sizeof(rect)="<<sizeof(rect)<<'\n' <<" sizeof(rect1)="<<sizeof(rect1)<<std::endl; } /* - output - Rect rect.bottom=12 RECT rect1.bottom=12 RECT rect1a.bottom=14 Rect rect2.top=10 sizeof(rect)=16 sizeof(rect1)=16 */ Sorry about that. [ I don't remember what I was 'testing' with the 'virtual inherit', something to do with "vector<RECT*> vRec(10, new MyRect(1,2,3,4));". ] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Why can't PODs have constructors?
Top