笔试题程序的输出

时间:2018-12-31 12:00:00 资料大全 我要投稿

笔试题(程序的输出)

分析一下这段程序的输出 (Autodesk)

笔试题(程序的输出)

class B

{

public:

B()

{

cout<<"default constructor"<<endl;

}

~B()

{

cout<<"destructed"<<endl;

}

B(int i):data(i)    //B(int) works as a converter ( int -> instance of B)

{

cout<<"constructed by parameter " << data <<endl;

}

private:

int data;

};

B Play( B b)

{

return b ;

}

(1)                                            results:

int main(int argc, char* argv[])       constructed by parameter 5

{                                     destructed B(5)形参析构

B t1 = Play(5); B t2 = Play(t1);     destructed t1形参析构

return 0;               destructed t2 注意顺序!

}                                      destructed t1

(2)                                    results:

int main(int argc, char* argv[])       constructed by parameter 5

{                                     destructed B(5)形参析构

B t1 = Play(5); B t2 = Play(10);     constructed by parameter 10

return 0;               destructed B(10)形参析构

}                                     destructed t2 注意顺序!

                                      destructed t1
 

【笔试题(程序的输出)】相关文章:

1.程序类笔试题

2.笔试题(优化程序)

3.笔试题(输入输出设备)

4.360笔试题目

5.360笔试题目

6.常规的C程序笔试题

7.C/C++程序员必备资料 常见笔面试题深入解析

8.笔试题(解释程序)