由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 请教个Bloomberg 的 C++ 题目
相关主题
一个c++ constructor的问题, thanks我真不明白c++有什么难的
菜鸟请教smart pointer几个问题
[合集] C++ interview question help有大侠讲讲RTTI和exception的问题么?
急问:compile and build dependency包含指针的类和vector的问题
请教一下,exception时,destructor一定会被调用么?What is wrong with the constructor calling?
用包子呼唤大牛们--问关于C++Destructor的问题请教一个基本的constructor和destrcutor问题
question regarding effective c++ by Meyers问个题。
c++ initialize struct请教这个程序里用到了什么constructor啊?有几个copy constructor?
相关话题的讨论汇总
话题: step话题: base话题: func话题: called
进入Programming版参与讨论
1 (共1页)
b*******e
发帖数: 34
1
How many constructor (including copy constructor) and destructors will be
called for test1 and test2?
Test1:3 constructors and destructors
Step-1 Default constructor will be called at Base a;
Step-2 Copy constructor will be called when passing a as formal parameter i.
e func(a).
Step-3 Copy constructor will be called for return object.
Step-4 Destructor will be called for actual parameter of func.
Step-5 Now this return obj will act as nameless obj in test1() and will get
destroy after line func
g*******y
发帖数: 1930
2
test2可能会有NRVO。应该是compiler-dependent。
http://msdn.microsoft.com/en-us/library/ms364057%28VS.80%29.aspx

i.
get

【在 b*******e 的大作中提到】
: How many constructor (including copy constructor) and destructors will be
: called for test1 and test2?
: Test1:3 constructors and destructors
: Step-1 Default constructor will be called at Base a;
: Step-2 Copy constructor will be called when passing a as formal parameter i.
: e func(a).
: Step-3 Copy constructor will be called for return object.
: Step-4 Destructor will be called for actual parameter of func.
: Step-5 Now this return obj will act as nameless obj in test1() and will get
: destroy after line func

w**********8
发帖数: 121
3
Base() // base a
Base(const Base&)// func(a)
Base(const Base&)// base b = return value
~Base()// b in func
~Base()// a
~Base()//b

i.
get

【在 b*******e 的大作中提到】
: How many constructor (including copy constructor) and destructors will be
: called for test1 and test2?
: Test1:3 constructors and destructors
: Step-1 Default constructor will be called at Base a;
: Step-2 Copy constructor will be called when passing a as formal parameter i.
: e func(a).
: Step-3 Copy constructor will be called for return object.
: Step-4 Destructor will be called for actual parameter of func.
: Step-5 Now this return obj will act as nameless obj in test1() and will get
: destroy after line func

1 (共1页)
进入Programming版参与讨论
相关主题
请教这个程序里用到了什么constructor啊?有几个copy constructor?请教一下,exception时,destructor一定会被调用么?
[合集] C++问题(copy constructor)用包子呼唤大牛们--问关于C++Destructor的问题
一道 memset in C++的题question regarding effective c++ by Meyers
C++的一个mutex问题c++ initialize struct
一个c++ constructor的问题, thanks我真不明白c++有什么难的
菜鸟请教smart pointer几个问题
[合集] C++ interview question help有大侠讲讲RTTI和exception的问题么?
急问:compile and build dependency包含指针的类和vector的问题
相关话题的讨论汇总
话题: step话题: base话题: func话题: called