Concepts of Programming Languages

(Sean Pound) #1

558 Chapter 12 Support for Object-Oriented Programming


public override void Draw() {... }

...
}


C# includes abstract methods similar to those of C++, except that they
are specified with different syntax. For example, the following is a C# abstract
method:

abstract public void Draw();

A class that includes at least one abstract method is an abstract class, and
every abstract class must be marked abstract. Abstract classes cannot be
instantiated. It follows that any subclass of an abstract class that will be instanti-
ated must implement all abstract methods that it inherits.
As with Java, all C# classes are ultimately derived from a single root
class, Object. The Object class defines a collection of methods, including
ToString, Finalize, and Equals, which are inherited by all C# types.

12.8.4 Nested Classes


A C# class that is directly nested in a class behaves like a Java static nested class
(which is like a nested class in C++). Like C++, C# does not support nested
classes that behave like the nonstatic nested classes of Java.

12.8.5 Evaluation


Because C# is the most recently designed C-based object-oriented language,
one should expect that its designers learned from their predecessors and
duplicated the successes of the past and remedied some of the problems. One
result of this, coupled with the few problems with Java, is that the differences
between C#’s support for object-oriented programming and that of Java are
relatively minor. The availability of structs in C#, which Java does not have,
can be considered an improvement. Like that of Java, C#’s support for object-
oriented programming is simpler than that of C++, which many consider an
improvement.

12.9 Support for Object-Oriented Programming in Ada 95


Ada 95 was derived from Ada 83, with some significant extensions. This section
presents a brief look at the extensions that were designed to support object-
oriented programming. Because Ada 83 already included constructs for building
abstract data types, the necessary additional features for Ada 95 were those for
supporting inheritance and dynamic binding. The design objectives of Ada 95
were to include minimal changes to the type and package structures of Ada 83
and retain as much static type checking as possible. Note that object-oriented
Free download pdf