Paradigm
Paradigm means organizing the program based on principle. It is an approach of to Programming.
Programming Paradigm
Programming Paradigm defines the methodology of designing and implementing programs using the key features and building block of programming language.
Programming Paradigm given an idea how problems are generally analyzed and solved in a particular programming language.
The some common Programming Paradigm are:
1. POP -:- Procedural Oriented Programming
2. OBP -:- Object Based Programming
3. OOP -:- Object Oriented Programming
PROCEDURAL ORIENTED PROGRAMMING
In POP or Procedural Programming the program is separates in Procedure or Function.
OBJECT BASED PROGRAMMING
Object Based Programming is newer paradigm that implements some features of object oriented programming but not all.
Object Based Programming is subset of Object Oriented Programming.
OBJECT ORIENTED PROGRAMMING
Object oriented programming provides ways of modularizing program by creating partition memory area for both data and function that can be used as template for creating copies of such module on demand.
In Object Oriented Programming the program is based on the class and object.
Object Oriented Programming is a superset of Object Based Programming.
The following OOP CONCEPTS are:
1. Object: An object is an identifiable entity with some characteristics and behavior.
2. Class: A class represents a group of objects that share common properties, behavior and relationships.
3. Data Abstraction: Abstraction refers to act of representing essential features without including the
background details or explanations.
4. Data Encapsulation: The wrapping up of data and associated functions into a single unit is known as
Encapsulation.
5. Data Hiding: The unessential features without including background details or explanation is called Data hiding.
6. Polymorphism: It is the ability for a message or data to be processed in more than one form. Polymorphism is a property by which the same message can be sent to objects of several different classes.
Polymorphism is implemented in C++ through virtual functions and overloading-function overloading and operator overloading.
7. Inheritance: It is the capability of one class of things to inherit capabilities or properties from another class.
The class which is inherited is called the base class or super class. And the class which inherits from another class is called derived class or sub class.
Advantages of Object oriented programming.
Software complexity can be easily managed.
Object-oriented systems can be easily upgraded
It is quite easy to partition the work in a project based on object.
Class enforce data-hiding, abstraction & encapsulation
A class groups its members into three sections: private, protected, and public.
The private and protected members remain hidden from outside world. Thus through private and protected members, a class enforces data-hiding.
The outside world is given only the essential and necessary information through public members, rest of the things remain hidden, which is nothing but abstraction. Abstraction means representation of essential features without including the background details and explanation.
The Wrapping up of data and function into single unit is called encapsulation.
Syntax of Class
class<<class_name>>
{
public:
[Data member]
[Member function]
private:
[Data member]
[Member function]
protected:
[Data member]
[Member function]
};
Syntax of Object
<<class_name>><<object _name>>;
Default section of Class is Private in C++.
Object Access member of class using dot operator.
Access Specifiers
Public members are accessible from anywhere where the object is visible. By default, all members of a class declared with the class keyword have private access for all its members. Therefore, any member that is declared before one other class specifiers automatically has private access.
Private members of a class are accessible only from within other members of the same class or from their friends.
Protected members are accessible from members of their same class and from their friends, but also from members of their derived classes.
for example
#include<iostream.h>
#include<conio.h>
#include<string.h>
class stud
{
int x; //data member
public:
void disp1()
{
cout<<"\n\tpublic section";
disp2();
disp3();
}
private:
void disp2()
{
cout<<"\n\tprivate section";
}
protected:
void disp3()
{
cout<<"\n\tprotected section";
}
};
void main()
{
clrscr();
stud obj;
obj.disp1();
getch();
}
Scope Resolution operator used for outside class Definition
No comments:
Post a Comment