r*******w 发帖数: 121 | 1 parameter passing...
还有什么时候? |
m******t 发帖数: 2416 | 2
Since you are posting on Java board, the answer would be "no, it doesn't
happen at parameter passing". 8-)
【在 r*******w 的大作中提到】 : parameter passing... : 还有什么时候?
|
r*******w 发帖数: 121 | 3 oops...you are right~~~
那copy constructor就没什么用了,其实?
除非我自己call?
【在 m******t 的大作中提到】 : : Since you are posting on Java board, the answer would be "no, it doesn't : happen at parameter passing". 8-)
|
m******t 发帖数: 2416 | 4
I would think so.
【在 r*******w 的大作中提到】 : oops...you are right~~~ : 那copy constructor就没什么用了,其实? : 除非我自己call?
|
F****n 发帖数: 3271 | 5 Is there any copy constructor in Java? What you guys are talking about?
【在 m******t 的大作中提到】 : : I would think so.
|
s******e 发帖数: 63 | 6 Copy constructor is the constructor for objects of class T which takes as
its single argument a reference to another object of class T. This
constructor builds a copy of the object passed by reference--hence the
name copy constructor.
you can define constructor method in Java class to mimic C++ copy constructor.
【在 F****n 的大作中提到】 : Is there any copy constructor in Java? What you guys are talking about?
|
r*******w 发帖数: 121 | 7 this is a pretty good news...
then i control everything ;-) no need to worry deep copy and shallow copy
anymore...
【在 m******t 的大作中提到】 : : I would think so.
|
e***g 发帖数: 158 | 8 there is no concept/support/usage of copy constructor; people rarely
copy objects in java anyways; your constructor is just a normal one.
if copy is indeed needed, clone() is the official way. it at least
has the advantage of polymophism, so that
Chick chick = ..;
Bird bird = chick;
bird.clone() returns a chick.
【在 s******e 的大作中提到】 : Copy constructor is the constructor for objects of class T which takes as : its single argument a reference to another object of class T. This : constructor builds a copy of the object passed by reference--hence the : name copy constructor. : you can define constructor method in Java class to mimic C++ copy constructor.
|
F****n 发帖数: 3271 | 9 这绝对属于拿C++的概念来乱套, C++ copy constructor, 只有在和赋值联系起来才
有意义,根本就不APPLY IN JAVA。
constructor.
【在 s******e 的大作中提到】 : Copy constructor is the constructor for objects of class T which takes as : its single argument a reference to another object of class T. This : constructor builds a copy of the object passed by reference--hence the : name copy constructor. : you can define constructor method in Java class to mimic C++ copy constructor.
|
r*******w 发帖数: 121 | 10 clone is a good idea...
however, in some cases i need shallow copy and in other cases i need deep
copy...therefore one method is not enough ah ;-)
either a copy constructor...or either a "copy" method is needed...
constructor.
【在 e***g 的大作中提到】 : there is no concept/support/usage of copy constructor; people rarely : copy objects in java anyways; your constructor is just a normal one. : if copy is indeed needed, clone() is the official way. it at least : has the advantage of polymophism, so that : Chick chick = ..; : Bird bird = chick; : bird.clone() returns a chick.
|
n*****k 发帖数: 123 | 11
come on, in C++, you still have to program a lot in order to have deep copy,
same thing in java, you have to override clone() method to have a deep copy
as you want.
【在 r*******w 的大作中提到】 : clone is a good idea... : however, in some cases i need shallow copy and in other cases i need deep : copy...therefore one method is not enough ah ;-) : either a copy constructor...or either a "copy" method is needed... : : constructor.
|