【1】写出下面程序的运行结果。
#include<iostream>
using namespace std;
class test
{ public:
test() ;
~test(){ };
private:
int i;
};
test::test()
{ i = 25;
for (int ctr=0; ctr<10; ctr++)
{ cout<<"Counting at "<<ctr<<"\n";
}
}
test anObject;
int main()
{ return 0;
}
【2】写出下面程序的运行结果。
#include<iostream>
using namespace std;
class Test{
private:
int val;
public:
Test()
{ cout<<"default."<<endl;
}
Test(int n)
{ val=n;
cout<<"Con."<<endl;
}
Test(const Test& t)
{ val=t.val;
cout<<"Copy con."<<endl;
}
};
int main()
{ Test t1(6);
Test t2=t1;
Test t3;
t3=t1;
return 0;
}
【3】指出下列程序中的错误,并说明为什么。
#include<iostream>
using namespace std;
class Student{
public:
void printStu();
private: