Reference type?

  • Thread starter Thread starter Jesper Denmark
  • Start date Start date
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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top