1 public abstract class Vehicle
2 {
3 public abstract void Drive();
4 }
5
6 public class Bicycle : Vehicle
7 {
8 public override void Drive()
9 {
10 System.Console.WriteLine("Bicycle.Drive()");
11 }
12 }
13
14 public class Car : Vehicle
15 {
16 public override void Drive()
17 {
18 System.Console.WriteLine("Car.Drive()");
19 }
20 }
21
22 public class Truck : Car
23 {
24 public override void Drive()
25 {
26 System.Console.WriteLine("Truck.Drive()");
27 }
28 }
29
30 void main()
31 {
32 System.UniquePtr<Vehicle> bicycle(new Bicycle());
33 bicycle->Drive();
34 System.UniquePtr<Vehicle> car(new Car());
35 car->Drive();
36 System.UniquePtr<Vehicle> truck(new Truck());
37 truck->Drive();
38 }