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

Interfaces

Recall the Shape class from the drawing program case study presented earlier. It contained the abstract method DrawYourself, which obliged any class derived from Shape to implement a DrawYourself method with the same signature and return type. In other words any class derived from Shape had to fulfill a contract saying: “I the derived class of Shape hereby promise to implement any abstract method contained in Shape or I shall be abstract myself”. This guarantee enabled us to call the different DrawYourself implementations in Circle, Triangle and Rectangle through dynamic binding. Notice that the Shape class didn't contain any data members or function member implementations and therefore didn't offer any code reuse benefits to its sub ...

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