Hi,
I'm using a very nice implementation of complex numbers
(by Ben Houston). There is a thing that is a bit unclear
though, why does the code in the main section below work
without creating the object with 'new'. Who is allocating
foo on the heap. What is hidded?, does it have anything
to do with the fact that it implements ICloneable.
or
code snippet:
static public Complex FromRealImagina ry( double real,
double imaginary )
{
Complex c;
c.Re = (double) real;
c.Im = (double) imaginary;
return c;
}
main
{
Complex foo;
foo = Complex.FromRea lImaginary(2,2) ;
Console.Writeli ne(foo);
}
I'm using a very nice implementation of complex numbers
(by Ben Houston). There is a thing that is a bit unclear
though, why does the code in the main section below work
without creating the object with 'new'. Who is allocating
foo on the heap. What is hidded?, does it have anything
to do with the fact that it implements ICloneable.
or
code snippet:
static public Complex FromRealImagina ry( double real,
double imaginary )
{
Complex c;
c.Re = (double) real;
c.Im = (double) imaginary;
return c;
}
main
{
Complex foo;
foo = Complex.FromRea lImaginary(2,2) ;
Console.Writeli ne(foo);
}
Comment