Objective-C Lecture 3 - Bhecker.com

mewlingtincupSoftware and s/w Development

Nov 9, 2013 (3 years and 9 months ago)

70 views

Introduction to

Objective
-
C Programming


(Level: Beginner)


Lecture 3

Derivation and Runtime binding

Derivation and runtime binding are the
most essential parts of Object Oriented
Programming

Derivation
-

Inheritance


Derivation is the syntactic mechanism for
inheritance


Inheritance is the semantic of derivation, it
expresses the meaning of derivation.


Derivation is a mechanism by which a class
acquires the methods and instance variables
of another class, called its superclass.

Inheritance in Objective
-
C

Initializers under inheritance

Inheritance is expressed in the new class’s interface declaration


@interface GradStudent : Student

{//additional instance variables


NSString* major;

}

// list inherited method to override

// list new methods of GradStudent for example a

// designated inititializer for GradStudent


-
(id)initGradStudent(NSString*)name :(float)gpa
:(NSString*) major;


Runtime binding

This is the decision during runtime which
method to execute when a message is sent to
an object. The executed message depends on
the type of the object.



The message can be sent through the typeless
pointer id.