Programming Language Concept

Just another Binusian blog site

Session 9 : Object-Oriented Programming

December9

Introduction

  • Many object-oriented programming (OOP) languages

–Some support procedural and data-oriented programming (e.g., Ada 95+ and C++)

–Some support functional program (e.g., CLOS)

–Newer languages do not support other paradigms but use their imperative structures (e.g., Java and C#)

–Some are pure OOP language (e.g., Smalltalk & Ruby)

–Some functional languages support OOP, but they are not discussed in this chapter

Object-Oriented Programming

  • Three major language features:

–Abstract data types (Chapter 11)

–Inheritance

  • Inheritance is the central theme in OOP and languages that support it

–Polymorphism

Design Issues for OOP Languages

  • The Exclusivity of Objects
  • Are Subclasses Subtypes?
  • Single and Multiple Inheritance
  • Object Allocation and Deallocation
  • Dynamic and Static Binding
  • Nested Classes
  • Initialization of Objects

Support for OOP in C++

  • General Characteristics:

–Evolved from C and SIMULA 67

–Among the most widely used OOP languages

–Mixed typing system

–Constructors and destructors

–Elaborate access controls to class entities

  • Inheritance

–A class need not be the subclass of any class

–Access controls for members are

–Private (visible only in the class and friends) (disallows subclasses from being subtypes)

–Public (visible in subclasses and clients)

–Protected (visible in the class and in subclasses, but not clients)

  • Multiple inheritance is supported

–If there are two inherited members with the same name, they can both be referenced using the scope resolution operator (::)

class Thread { … }

class Drawing { … }

class DrawThread : public Thread, public Drawing { … }

Implementing OO Constructs

  • Two interesting and challenging parts

–Storage structures for instance variables

–Dynamic binding of messages to methods

Email will not be published

Website example

Your Comment: