Saturday, January 5, 2008

OOPS Overview

Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs.

Fundamental concepts

Class: A class defines the characteristics of a thing. namely the state (attributes, fields or properties) and behavior (methods, operation or features). For example a Vehicle is an example of a class.
Object: An object is an instance of the class. In the case of our example, a car can be considered as an object of the class vehicle.

The different OOPS techniques are
1. Abstraction
2. Encapsulation
3. Polymorphism
4. Inheritence

Abstraction:

This is the process of hiding the complexity and the inner workings of a class, so that users dont have to know how it operates.

Encapsulation:

The process of every object that binds togeter the data and code it required to operate upon.

Polymorphism

This the term given to different objects being able to perform the same action but through different implementation. The dynamic polymorphism or Run time polymorphism means, complier would comes to know which method to execute, at the run time not in compile time.We can Implement the Run time polymorphism by using the Override Key word.And in the base class that method should be a virtual method. The static polymorphism or compile time polymorphism means, compiler knows which method to execute at compile time. We can implement compile time polymorphism using function overloading or operator overloading.

Inheritance

The inheritance defines how classes can be related to one another and share the characteristics. It is the property by which an object can get the properties and behavior of other object.
A class that is inherited is called a base class. A class which is inheriting another class is called a derived class. When a class inherits another class, members of the base class become the members of the derived class. The general form of inheritance is:-

class derivedClassName : BaseClassName
{
};

No comments: