高等继续教育 / 面向对象程序设计
题型描述: 简答题
分析一下这段程序的输出:
class B
{
public:
B()
{
cout<<"default constructor"< }
~B()
{
cout<<"destructed"< }
B(int i):data(i) //
{
cout<<"constructed by parameter " << data < }
private:
int data;
};
B Play( B b)
{
return b ;
}
int main(int argc, char* argv[])
{
B t1 = Play(5);
B t2 = Play(t1);
return 0;
}
分析一下这段程序的输出:
class B
{
public:
B()
{
cout<<"default constructor"<
~B()
{
cout<<"destructed"<
B(int i):data(i) //
{
cout<<"constructed by parameter " << data <
private:
int data;
};
B Play( B b)
{
return b ;
}
int main(int argc, char* argv[])
{
B t1 = Play(5);
B t2 = Play(t1);
return 0;
}
参考答案:
佳题速递: