Mail Archives: djgpp/1997/02/08/20:40:46
You are lucky, lots of replies to your post.
I asked why the first example did not compile and did not get a reply.
At least K.A.R.L. got it to work. I'd be interested in any comments.
Regards Ian
#include <stdio.h>
// --- class TObject1 definition
class TObject1
{ public:
TObject1();
virtual void foo();
};
TObject1::TObject1()
{ foo();
}
void TObject1::foo()
{ printf("TObject1::foo\n");
}
// --- class TObject2 definition
class TObject2 : public TObject1
{ public:
TObject2();
virtual void foo();
}
TObject2::TObject2() : TObject1()
{ }
//************* ERROR return type spec for constructor invalid.
void TObject2::foo()
{ printf("TObject2::foo\n");
}
void main(void)
{ TObject1 *O1;
//*******Warning return type for main changed to integer type.
TObject2 *O2;
printf("TObject1 creation : ");
O1=new
TObject1();
printf("TObject2 creation : ");
O2=new TObject2();
//
delete O2;
delete O1;
}
- Raw text -