Anda di halaman 1dari 15

Introduction to c++

Object Class Data Abstraction & Encapsulation Inheritance Polymorphism Dynamic Binding Message Passing

Objects
Object is the basic unit of object-oriented programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data. An Object is a collection of data members and associated member functions also known as methods.

Class
Classes are data types based on which objects are created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represents a set of individual objects.

Data abstraction & Encapsulation


The wrapping up of data and its functions into a single unit is called Encapsulation. Data Abstraction increases the power of programming language by creating user defined data types. //eg: class n objects

Inheritance
Inheritance is the process of forming a new class from an existing class or base class. The base class is also known as parent class or super class, the new class that is formed is called derived class. Derived class is also known as a child class or sub class.

Base Class Existing class is called Base Class. Father

Raj

Rani

Roshan

Derived Class

New class is called derived class.

INHERITANCE

SINGLE INHERITANCE

MULTIPLE INHERITANCE

MULTILEVEL INHERITANCE

HIERARCHICAL INHERITANCE

HYBRID INHERITANCE

When a subclass inherit only from one base class,it is known as single inheritance. Super Class (Base Class)

Super Class

Sub Class (Derived Class)

Derived Class

Syntax:

Colon gives that derived class-name is derived from base-class.

Class Derived-class : Mode base-class { St1; St2; }; Mode is either private or public.By
default mode is private

Name of different base class

Syntax:
Class Derived-class : Mode base-class1,Mode base-class2

{
St1; St2; };
Mode is either private or public.By default mode is private

Super Class

Sub Class 1 Sub Class 2 When a subclass inherits from a class that itself inherits from another class it is known as multilevel inheritance.Slide 6

When one subclass inheriting from many base class ,it is known as hierarchical inheritance.Syntax:

polymorphism
Poly a Greek term ability to take more than one form. Overloading is one type of Polymorphism. It allows an object to have different meanings, depending on its context.

Dynamic binding
It contains a concept of Inheritance and Polymorphism

Message Passing
It refers to that establishing communication between one place to another.

Anda mungkin juga menyukai