请c++高手来阅读下下列程序~~!!!写出运行结果~~谢谢~~!!!

来源:百度知道 编辑:UC知道 时间:2024/09/25 09:30:47
阅读以下程序写出运行结果:
1. #include<iostream>
using namespace std;
class Test
{
private:
int num;
public:
Test();
Test(int n);
~ Test(){cout<<"dst "<<num<<endl;}
};
Test::Test()
{
cout<<"Init defa"<<endl;
num=0;
}
Test::Test(int n)
{
cout <<"Init"<<" "<<n<<endl;
num=n;
}
int main()
{
Test xx(10);
Test yy[2];
return 0;
}

2. #include<iostream>
using namespace std;
class My
{
public:
My(int aa)
{
A=aa;
B-=aa;
}
static void fun(My m);
private:
int A;
static int B;
};
void My::fun(My m)
{
cout<<"A="<<m.A<<endl;
cout<<"B="<<B<<endl; }
int My::B=100;
int mai

以下运行结果都已经通过VC6.0编译确认

1.
运行结果为:
Init 10
Init defa
Init defa
dst 0
dst 0
dst 10

2.
运行结果为:
A=8
B=86
A=6
B=86

3.
运行结果为:
a+b=14

4.
运行结果为:
cst big a=18
cst small d=190
dst small d=190
dst big a=18

1.
运行结果为:
Init 10
Init defa
Init defa
dst 0
dst 0
dst 10

2.
运行结果为:
A=8
B=86
A=6
B=86

3.
运行结果为:
a+b=14

4.
运行结果为:
cst big a=18
cst small d=190
dst small d=190
dst big a=18