由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - [合集] C++问题(copy constructor)
相关主题
C++里面请教各路C++大神 为什么f(3) 输出是 'dd'
关于c++的constructor的面试题用包子呼唤大牛们--问关于C++Destructor的问题
[合集] 关于C++ default copy constructorC++问题,confusing...
C++的一个小疑问,求解惑C++的一个mutex问题
请教一个基本的constructor和destrcutor问题c++ copy reference 还是deep copy
C++默认的copy constructor的疑惑菜鸟请教smart pointer
关于C++ copy-constructor 一个奇怪的问题What is wrong with the constructor calling?
question about c++ constructorWhat is wrong with the constructor (or the code)?
相关话题的讨论汇总
话题: func话题: c++话题: sat话题: jun
进入Programming版参与讨论
1 (共1页)
c***d
发帖数: 996
1
☆─────────────────────────────────────☆
geome (Derivative) 于 (Sat Jun 16 16:21:11 2007) 提到:
#include
using namespace std;
class A{
public:
A(){}
A(A& a){cout<<"copying"< };
A func(A a){
return a;
}
int main(){
A a;
A b=func(a);
return 1;
}
不能编译.
但是如果把 A b=func(a);换成func(a);就可以了.
或者把 A(A& a)换成A(const A& a)也可以编译通过.
按照第二个办法来看,compiler怕A b=func(a)改变了func里面的临时变量,但是func(a)
也会产生同样
的问题啊???不明白...
☆─────────────────────────────────────☆
std (解不了名缰系嗔贪) 于 (Sat Jun 16 17:42:48 2007)
1 (共1页)
进入Programming版参与讨论
相关主题
What is wrong with the constructor (or the code)?请教一个基本的constructor和destrcutor问题
请教个Bloomberg 的 C++ 题目C++默认的copy constructor的疑惑
请教这个程序里用到了什么constructor啊?有几个copy constructor?关于C++ copy-constructor 一个奇怪的问题
C++ 中 myobject * a =new myobject[n] 的问题question about c++ constructor
C++里面请教各路C++大神 为什么f(3) 输出是 'dd'
关于c++的constructor的面试题用包子呼唤大牛们--问关于C++Destructor的问题
[合集] 关于C++ default copy constructorC++问题,confusing...
C++的一个小疑问,求解惑C++的一个mutex问题
相关话题的讨论汇总
话题: func话题: c++话题: sat话题: jun