C ++ learning notes

xiaoxiao2021-03-06  42

#include "iostream.h"

Class A

{

PUBLIC:

A ()

{

COUT << "A ()" << endl;

}

Virtual ~ a ()

{

Cout << "~ a ()" << Endl;

}

}

Class B

{

PUBLIC:

B ()

{

COUT << "b ()" << endl;

}

Virtual ~ b ()

{

Cout << "~ b ()" << endl;

}

}

void main ()

{

A a a;

B B;

}

The above code output results:

A ()

B ()

~ B ()

~ A ()

As can be seen from the above results, the most declared object in C is first constructed, and finally destructive.

转载请注明原文地址:https://www.9cbs.com/read-73366.html

New Post(0)