J
Jesper Denmark
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.
http://www.csharphelp.com/archives/archive284.html
or
http://www.codeproject.com/csharp/exocortex.asp
code snippet:
static public Complex FromRealImaginary( double real,
double imaginary )
{
Complex c;
c.Re = (double) real;
c.Im = (double) imaginary;
return c;
}
main
{
Complex foo;
foo = Complex.FromRealImaginary(2,2);
Console.Writeline(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.
http://www.csharphelp.com/archives/archive284.html
or
http://www.codeproject.com/csharp/exocortex.asp
code snippet:
static public Complex FromRealImaginary( double real,
double imaginary )
{
Complex c;
c.Re = (double) real;
c.Im = (double) imaginary;
return c;
}
main
{
Complex foo;
foo = Complex.FromRealImaginary(2,2);
Console.Writeline(foo);
}