O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

abstract Methods, Properties, Indexers, and Classes

The Car class in Listing 16.3 of Chapter 16 contained a definition (shown next) for the MoveForward method that added 1 to the odometer variable.

19:     public virtual void MoveForward()
20:     {
21:         Console.Write("Moving forward... ");
22:         odometer += 1;
23:         Console.WriteLine("Odometer reading: { 0} ", odometer);
24:     }

However, as noted in the same section, MoveForward could mean anything in the generic Car class for which it was defined. The implementation of MoveForward in the Car class was merely meant to be a dummy implementation waiting to be overridden in the FamilyCar, SportsCar, and RacingCar classes where we had a better idea of how to implement it (FamilyCar is slow, SportsCar is medium ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required