以下程序的运行结果是:
#include <iostream.h>
class C
{
int i;
public:
C();
C(int val);
void Display();
~C();
};
C :: C()
{
cout << "Constructor1" << endl;
i = 0;
}
C :: C(int val)
{
cout << "Constructor2" << endl;
i = val;
}
void C :: Display()
{
cout << "i = " << i << end;
}
C :: ~C()
{
cout << "Destructor" << endl;
}
void main()
{
C a,b(10);
a.Display();
b.Display();
}
__________________
__________________
___________________
___________________
___________________
___________________