#include<iostream>
using namespace std;
class exam{
public:
exam(int a)
{
n=a;
}
exam()
{
n=123;
}
int get()
{
return n;
}
private:
int n;
};
int main()
{
exam a[4]={11,22,33,44};
for(int i=0;i<4;i++)
{
cout<<a[i].get()<<" "<<endl;
}
exam b[4]={1,22};
for(int i=0;i<4;i++)
{
cout<<b[i].get()<<" "<<endl;
}
return 0;
}
结果:
11
22
33
44
1
22
123
123
Process exited after 0.02601 seconds with return value 0
请按任意键继续. . .