Example of c\; operator overloading

From , 2 Years ago, written in C#, viewed 230 times.
URL https://pastebin.vip/view/b4aa00bc
  1. public class Plane {
  2.       public virtual double TopSpeed() { return 300.0D;}
  3.       public static bool operator>(Plane one, Plane two) {  
  4.          return one.TopSpeed() > two.TopSpeed();
  5.       }
  6.       public static bool operator<(Plane one, Plane two) {  
  7.          return one.TopSpeed() < two.TopSpeed();
  8.       }
  9.    }
  10.    class Jet : Plane {
  11.       public override double TopSpeed() { return 900.0D; }
  12.       public override string ToString() { return "I'm a Jet"; }
  13.    }
  14.       class Airport {
  15.       [STAThread]
  16.       static void Main(string[] args) {
  17.          Plane plane = new Jet();
  18.          Console.WriteLine("plane's top speed: {0}",plane.TopSpeed());
  19.          Jet jet = new Jet();
  20.          Console.WriteLine("jet's top speed: {0}",jet.TopSpeed());
  21.          Console.WriteLine("Plane > Jet = {0}", plane > jet);
  22.          Console.ReadLine();
  23.       }
  24.    }
  25. //csharp/4821

Reply to "Example of c\; operator overloading"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website