Re: Why can't PODs have constructors?
JohnQ <johnqREMOVETHISprogrammer@yahoo.com> wrote in message...
"BobR" wrote in message...
struct MyRect : public virtual RECT{
Why the virtual inheritance?
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));". ]
--
Bob R
POVrookie