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.
相关阅读
请教参数传递问题distributedOpenShift怎么上数据库?版上有懂zookeeper原理的吗一般来说多大的数据量可以称为海量数据呢?如何学习 Hadoop问一个blocking IO的程序问个linux的问题网上信用卡支付的java code怎么写?JMS这东西用的多吗?Eclipse还是IntelliJ是学java还是c#Spring例子求解释Google App Engine顽固错误跪求解决办法Java 有类似 leetcode那样子的网站吗?怎样截取网页<div></div>中多个<p></p>之间的内容?一个server如果想把一些api作为public,一些作为private,一般都有什么办法?goodbug, aws上怎么实现web server,app server分离,2个firewall的?请教frameworkCassandra2.0好用吗?