s*e
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?
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?
e*g
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.
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
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.
有意义,根本就不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
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.
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
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.
相关阅读
现在 Java Web 开发过时了么?为什么我这个参数的内容存不下?被面how to manage heap in java jvmhow to convert local file path to UNC path?请教一题我也来问问题了目测netflix形势一片大好啊请问最佳的方案:在其他项目基础上扩展关于RMI的问题leetcode longest consecutive sequence还是想不通!问下Java开源平台趋势公司面试题汇总文件的link? (转载)求Spring MVC 简单的例子Java Map 存 1 million 记录在手机上怎么远程控制一个房间的灯亮灯灭?When running a .jar file, error message: cannot connect to window serverjava code coverage 现在都用什么如何设置java和flex的调试环境?java str.replaceAll("\n", "") doesn't work大家用哪个免费的网站,自己把code upload上去? (转载)