由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to make sure that I get the original object or only a copy (not original) in such situation?
相关主题
弱问:C#定义的class里面直接new出来的成员存在了哪里?windows 下怎么让同一个程序的不同instance之间通信呢
another c++ interview questionhow to create an instance of base class in its derived class definition
[c++] static function in a class[合集] C++ private member question
C++做题,麻烦师傅们再看看。What is "number of bits set"?
请教goodbug等大神几个AWS的问题谁熟dotnet 的webservice?
请教高手一个C++问题请教C++面试题
how to initialize this struct.python里面的__slot__是用来做什么?
Global(static) variable initialization question[合集] 为什么很少有人用static来实现signleton?
相关话题的讨论汇总
话题: coordinate话题: original话题: sure话题: make话题: copy
进入Programming版参与讨论
1 (共1页)
c*********n
发帖数: 128
1
Let's say I have a class name Coordinate and have its instances:
Coordinate a;
Then I have the following line:
Coordinate b = a;
In some cases, I wanna b to the same instance of a, i.e., &a and &b are the
same, how to make sure of that?
In other cases, I wanna b to only a copy of a, i.e, the fields within
instance b are all the same as that of a but &a and &b are different. How to
make sure of this?
Thanks.
H***a
发帖数: 735
2
If I understand ur questions correctly,the answer would be
(1) Coordinate& b=a;
(2) Coordinate b=a;
And you had better define the "=" yourself.
d*****a
发帖数: 110
3
Usually "=" needs to be explicitly defined if any deep-copy operations.

【在 H***a 的大作中提到】
: If I understand ur questions correctly,the answer would be
: (1) Coordinate& b=a;
: (2) Coordinate b=a;
: And you had better define the "=" yourself.

1 (共1页)
进入Programming版参与讨论
相关主题
[合集] 为什么很少有人用static来实现signleton?请教goodbug等大神几个AWS的问题
请问关于c++实现singleton的问题?请教高手一个C++问题
C++问题几个how to initialize this struct.
一个C的问题:从一个instance到多个instance的改动Global(static) variable initialization question
弱问:C#定义的class里面直接new出来的成员存在了哪里?windows 下怎么让同一个程序的不同instance之间通信呢
another c++ interview questionhow to create an instance of base class in its derived class definition
[c++] static function in a class[合集] C++ private member question
C++做题,麻烦师傅们再看看。What is "number of bits set"?
相关话题的讨论汇总
话题: coordinate话题: original话题: sure话题: make话题: copy