完成下列程序,使得该程序输出结果如下:
number of instance: 1
number of instance: 2
number of instance: 1
number of instance: 0
#include "iostream.h"
class Process
{
static int instance;
public:
Process( )
{
1
}
~Process( )
{
2
}
static void print( )
{
cout << "number of instance: " << instance << endl;
}
};
3
int main( )
{
Process *p1, *p2;
p1 = new Process;
p1->print( );
p2 = new Process;
p2->print( );
delete p1;
Process::print( );
delete p2;
Process::print( );
return 0;
}