Skip to content

Instantly share code, notes, and snippets.

@aruld
Created October 19, 2011 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aruld/1299024 to your computer and use it in GitHub Desktop.
Save aruld/1299024 to your computer and use it in GitHub Desktop.
Dart operator overloading complex types
class Complex {
Complex(this.re, this.im);
double re, im;
operator +(Complex other) {
return new Complex(re + other.re, im + other.im);
}
void Display( ) {
print('$re,$im');
}
}
main() {
Complex a = new Complex( 1.2, 3.4 );
Complex b = new Complex( 5.6, 7.8 );
Complex c = new Complex( 0.0, 0.0 );
c = a + b;
c.Display();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment