Hello Daniel O'Connell [C# MVP],
thanks!
copy construct can get new object, such as :
public class Test
{
private int a;
private string s;
private Hashtable h;
public Test()
{
a = 10;
s = "hello";
h = new Hashtable;
}
public Test(Test t)
{
a = t.a;
s = t.s;
h = t.h;//copy?
h = (Hashtable)t.h.Clone() // shadow copy
}
public void func()
{
ClassA testa = new ClassA();
ClassA testb = new ClassA();
h.Add("a",testa);
h.Add("b",testb);
a = 15;
}
}
void main()
{
private Test a = new Test();
a.func();
private Test b = new Test(a); //here b.h have testa and testb
and b.a = 15
//object b is a new object, I want b.h is a new Hashtable
private Test c = new Test(); // here c.h has no element and
c.a = 10
c = a; // c is a refrence ,not I want
}
"harvie wang" <qu*****@gmail.com> wrote in message
news:5e**************************@news.microsoft.c om...
Hello Daniel O'Connell [C# MVP],
thanks!
Is the class A can do the copy work?
private A a = new A();
a.func();
private A b = new B();
b = a;//
now b._data have a ClassA object? have a handle of object?
b would be a reference that a had. You will not get C++ style
assignmnt copying.
ClassA a = (ClassA)b._data["a"];
ClassA b = (ClassA)a._data["a"];
AddressOf(a) isn't equal to AddressOf(b)?
I'm not sure what you mean here.