由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - C++ constructor problem
相关主题
包子呼唤大牛--问关于C++Destructor的问题 (转载)Bloomberg网上测试题
请问这个C++问题对吗?问几个跟C++有关的面试题
C++ Q47: protected constructor (C39)问个C++的题目
Qualcomm Phone Interbview面筋,赚RP问个C++重新编译的问题
贴一道take home的面试题一道 C++ 的题。
今早Bloomberg电话面试经过,奉献给大家。。。C++面试问题,高人请进啊~~~
新Qualcomm面经请教1个工作面试题
再帖一遍Amazon Onsite的题为什么C++的constructor出错可以抛出异常,而destructor出错
相关话题的讨论汇总
话题: base话题: endl话题: cout话题: test1
进入JobHunting版参与讨论
1 (共1页)
n*******s
发帖数: 482
1
code :
class Base{
public:
Base(){cout << "Base()" << endl;}
Base(const Base&){cout << "Base(const Base&)" << endl;}
~Base(){cout << "~Base()" << endl;}
};
Base func(Base b){return b;}
void test1(){
Base a;
func(a);
}
void test2(){
Base a;
Base b = func(a);
}
int main(){
test1();
cout<<"----------"< test2();
return 0;
}
// from the output,
test1() will
1. first call Base's default constructor for "Base a"
2. call Base's copy constructor since parameter is passed by value
3. call Base
s*******s
发帖数: 1568
2
return value optimization, you can refer more effective c++

【在 n*******s 的大作中提到】
: code :
: class Base{
: public:
: Base(){cout << "Base()" << endl;}
: Base(const Base&){cout << "Base(const Base&)" << endl;}
: ~Base(){cout << "~Base()" << endl;}
: };
: Base func(Base b){return b;}
: void test1(){
: Base a;

n*******s
发帖数: 482
3
got it. Shame on me, I read More Effective last year...

【在 s*******s 的大作中提到】
: return value optimization, you can refer more effective c++
c****p
发帖数: 32
4
从汇编看很清楚:D
http://www.codepp.com/default.aspx?g=posts&m=59&#post59

【在 n*******s 的大作中提到】
: code :
: class Base{
: public:
: Base(){cout << "Base()" << endl;}
: Base(const Base&){cout << "Base(const Base&)" << endl;}
: ~Base(){cout << "~Base()" << endl;}
: };
: Base func(Base b){return b;}
: void test1(){
: Base a;

1 (共1页)
进入JobHunting版参与讨论
相关主题
为什么C++的constructor出错可以抛出异常,而destructor出错贴一道take home的面试题
刚phone完MS,好紧张。。。。今早Bloomberg电话面试经过,奉献给大家。。。
Please help on Effective C++ Item 11新Qualcomm面经
发发我自己的Bloomberg的面经再帖一遍Amazon Onsite的题
包子呼唤大牛--问关于C++Destructor的问题 (转载)Bloomberg网上测试题
请问这个C++问题对吗?问几个跟C++有关的面试题
C++ Q47: protected constructor (C39)问个C++的题目
Qualcomm Phone Interbview面筋,赚RP问个C++重新编译的问题
相关话题的讨论汇总
话题: base话题: endl话题: cout话题: test1