I'm studying ICT. One of my courses is C# and another is Physics. Our Physics teacher used Visual Studio to animate some movements gave us some of the code he used to do it. He told us to look it up. Here's something I don't recognize:
public static Vector operator + (Vector v1, Vector v2)
{
return new Vector(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z);
}
That is supposed to be a constructor, but I've never seen anything like it before. I don't know what it's called, so I don't know what to google for.
Can someone enlighten me please?
That is called "operator overloading". It is not a constructor but returns a new Vector.
See: Operator Overloading
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With