Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone references #20

Open
rafacallejo opened this issue Dec 11, 2023 · 0 comments
Open

Clone references #20

rafacallejo opened this issue Dec 11, 2023 · 0 comments

Comments

@rafacallejo
Copy link

I have and object like that:

Person (string Name, Person subp1, Person subp2)

If i create

P1=new Person ("p1",null,null)

and then

P2= new ("p2",P1,P1)

and i clone this P2 object as P3, its very strange but first child subp1 creates a new object but subp2 gets linked to the original.

P3.subp1 memory address is different of P2.subp1 "BUT" P3.subp2 and P2.subp2 have the same memory address, so any changes on the subp2 original gets replicated on the cloned instance and viceversa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant