Oops, there're a few syntax error.  But you get the idea.

On 22 Oct 2003 at 16:34, John Leung wrote:

> It is a "good" practice for base class' destructor to be virtual.  However, it
> is not absolutely necessary and it won't always cause problem if you avoid the
> special case.  The following is the special case when your derived class
> destructor would be skipped if your base class' destructor isn't virtual:
> 
> Class A
> {
>  public:
>   A() { cout << "Called Class A Constructor\n" << flush;
>        ~A() { cout << "Called Class A Destructor\n" << flush;
> };
> 
> Class B : public A
> {
>  public:
>   B() { cout << "Called Class B Constructor\n" << flush;
>        ~B() { cout << "Called Class B Destructor\n" << flush;
> };
> 
> void main()
> {
>     cout << "Test 1: Class B destructor will be skipped\n" << flush;
>  A *b1 = new B;
>  delete b1;
>  cout << "Test 2: Everything is OK\n" << flush;
>  B b2;
> }
> 
> 
John Leung
[EMAIL PROTECTED]
http://persweb.direct.ca/jleung


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to