Beruflich Dokumente
Kultur Dokumente
------------------------------------------
Conventinal programming using high level languages such as
cobol,fortran and c is commonly known as procedure oriented programming(pop).in the
procedure oriented approach the problem is viewed as a sequence of things to be
done such as reading,calculating and printing.
Characteristics of pop
1. Emphasis is on doing things(algorithms).
2. large programs are divided into smaller programs known as functions
3. most of the functions share global data .
4. data move openly around the system from function to function
5. functions transform data from one form to another.
6. employs top-down approach in program design
concepts of oop
1. Objects
2. Classes
3. Data Abstraction and Encapsulation
4. Inheritance
5. polymorphism
6. dynamic binding
7. message passing
1. objects
Objects are the basic run time entities in an object oriented system.
programming problem is analyzed interms of objects and the nature of communication
between them.
obejcts take up space in the memory and have an associated address.
when a program is executed the obejcts interact by sending messages to one
another.each object contains data and code to manipulate the data.
2. Classes.
Objects contain data and code to manipulate the data.the entire set
of data and code of an object can be made a user defined data type with the help of
a class.
Objects are variables of the type class. once a class has been defined,we can
create any number of obejcts belonging to that class.
each object is associated with the data of type class with which they are
created. a class is a thus a collection of objects of similar type.
4. Inheritance
Inheritance is the process by which objects of one class
acquire the properties of objects of another class. the concept of inheritance
provides the idea of Reusability.
5. Polymorphism
It is Another important oop concept.
polymorphism means the ability to take more than one form.
the behavior depends upon the types of data used in the operation.
the process of making an operation to exhibit different behaviours
in different instances is known as operator overloading.
6. Dynamic Binding
Binding refers to the linking of a procedure call to the code to be executed
in response to call. dynamic binding means that the code associated with a given
procedure call is not known until the time of the call at run time. it is
associated with polymorphism or inheritance. a function call associated with a
polymorphism reference depends on the dynamic type of that reference.
7. Message Passing
An Object oriented program consists of a set of objects communicate with each
other.
Access Specifiers
--------------------
There are 3 types of Access Specifiers
1. private
2. public
3. protected
1. private
A key Feature of oop is data hiding. the primary mechanism for hiding data is to
put it in a class and make it private. private data or private member functions can
only be accessed from within the class.
2. public
public data or public member functions can only be accessed from outside the
class. usually the data within a class is private and the functions are public.
the data is hidden so it will be safe from accidental manipulation,while the
fuctions that operate on the data are public so they can be accessed from outside
the class.
3. protected
it is just like private. but it is used in derived classes.
a protected member can be accessed by member functions in its class or in any
derived class from its own class.any data or functions that the derived classes
might need to access should be made protected rather than private.
syntax of a class
class <class_name>
{
private:
// Data members
// member functions
public:
// data members
// member functions
};