<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
cloning	B-Application
refers	O
to	O
the	O
making	O
of	O
an	O
exact	O
copy	O
of	O
an	O
object	O
,	O
frequently	O
under	O
the	O
paradigm	O
of	O
instance-based	B-Application
programming	I-Application
,	O
or	O
object-oriented	B-Language
programming	I-Language
(	O
OOP	O
)	O
.	O
</s>
<s>
In	O
most	O
programming	O
languages	O
(	O
exceptions	O
include	O
Ruby	B-Language
)	O
,	O
primitive	O
types	O
such	O
as	O
double	O
,	O
float	O
,	O
int	O
,	O
long	O
,	O
etc	O
.	O
</s>
<s>
simply	O
store	O
their	O
values	O
somewhere	O
in	O
the	O
computer	O
's	O
memory	O
(	O
often	O
the	O
call	B-General_Concept
stack	I-General_Concept
)	O
.	O
</s>
<s>
Copying	O
primitive	O
types	O
in	O
Java	B-Language
or	O
C++	B-Language
:	O
</s>
<s>
Many	O
OOP	O
programming	O
languages	O
(	O
including	O
Java	B-Language
,	O
D	B-Application
,	O
ECMAScript	B-Language
,	O
and	O
C#	B-Application
)	O
make	O
use	O
of	O
object	O
references	O
.	O
</s>
<s>
A	O
Java	B-Language
example	O
,	O
when	O
"	O
copying	O
"	O
an	O
object	O
using	O
simple	O
assignment	O
:	O
</s>
<s>
The	O
process	O
of	O
actually	O
making	O
another	O
exact	O
replica	O
of	O
the	O
object	O
instead	O
of	O
just	O
its	O
reference	O
is	O
called	O
cloning	B-Application
.	O
</s>
<s>
In	O
most	O
languages	O
,	O
the	O
language	O
or	O
libraries	O
can	O
facilitate	O
some	O
sort	O
of	O
cloning	B-Application
.	O
</s>
<s>
In	O
Java	B-Language
,	O
the	O
Object	O
class	O
contains	O
the	O
clone( )	O
method	O
,	O
which	O
copies	O
the	O
object	O
and	O
returns	O
a	O
reference	O
to	O
that	O
copied	O
object	O
.	O
</s>
<s>
Since	O
it	O
is	O
in	O
the	O
Object	O
class	O
,	O
all	O
classes	O
defined	O
in	O
Java	B-Language
will	O
have	O
a	O
clone	B-Language
method	O
available	O
to	O
the	O
programmer	O
(	O
although	O
to	O
function	O
correctly	O
it	O
needs	O
to	O
be	O
overridden	O
at	O
each	O
level	O
it	O
is	O
used	O
)	O
.	O
</s>
<s>
Cloning	B-Application
an	O
object	O
in	O
Java	B-Language
:	O
</s>
<s>
C++	B-Language
objects	O
in	O
general	O
behave	O
like	O
primitive	O
types	O
,	O
so	O
to	O
copy	O
a	O
C++	B-Language
object	O
one	O
could	O
use	O
the	O
'	O
=	O
'	O
(	O
assignment	O
)	O
operator	O
.	O
</s>
<s>
There	O
are	O
dangers	O
when	O
using	O
this	O
technique	O
(	O
see	O
slicing	B-Application
)	O
.	O
</s>
<s>
A	O
method	O
of	O
avoiding	O
slicing	B-Application
can	O
be	O
implementing	O
a	O
similar	O
solution	O
to	O
the	O
Java	B-Language
clone( )	O
method	O
for	O
the	O
classes	O
and	O
using	O
pointers	O
.	O
</s>
<s>
(	O
There	O
is	O
no	O
built-in	O
clone( )	O
method	O
.	O
)	O
</s>
<s>
A	O
C++	B-Language
example	O
of	O
object	O
cloning	B-Application
:	O
</s>
<s>
A	O
C++	B-Language
example	O
of	O
object	O
cloning	B-Application
using	O
pointers	O
(	O
to	O
avoid	O
slicing	B-Application
see	O
)	O
:	O
</s>
