0% found this document useful (0 votes)
6 views

Object Oriented Programming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Object Oriented Programming

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

OBJECT ORIENTED PROGRAMMING

CONTENTS
❖ Object Oriented Programming
❖ Concept Of Object Oriented Programming
❖ Basic Object-Oriented Programming
❖ Data Members
❖ Members Function
❖ Advantages of OOPs
❖ Simple String Program
❖ Simple Integer Program
❖ Simple Character Program
❖ Simple Float Program
Concept Of Object Oriented Programming
Coop is a Programming pattern where the programs are structured around objects rather than
functions and logic.
It makes the data partitioned into two memory areas, i.e., data and functions, and helps make
the code flexible and modular.
Object-oriented programming mainly focuses on objects that are required to be manipulated.
In OOPs, it can represent data as objects that have attributes and functions.
Object Oriented Programming
Basic Object-Oriented Programming
❑ Object-An O Object can be defined as an entity that has a state and behavior is called an
object.
It can represent a dog, a person, a table, etc.
An object means the combination of data and programs, which further represent an entity.

❑ Classes-Class can be defined as a plan of the object.


It is basically a collection of objects which act as building blocks.
Basic Object-Oriented Programming (cont)
Abstraction- Abstraction helps in the data hiding process. It helps in displaying the essential
features without showing the details or the functionality to the user. It avoids unnecessary
information details and shows only that specific part which the user wants to see.
Basic Object-Oriented Programming
❑Encapsulation- The wrapping up of data and functions together in a single unit is
known as encapsulation. It can be achieved by making the data members' scope
private and the member function’s scope public to access these data members.
Encapsulation makes the data non-accessible to the outside world.
Basic Object-Oriented Programming
Inheritance- Inheritance is the process in which two classes have an is-a relationship among each
other and objects of one class acquire properties and features of the other class. The class which
inherits the features is known as the child class, and the class whose features it inherited is called
the parent class. For example, Class Vehicle is the parent class, and Class Bus, Car, and Bike are
child classes.
Basic Object-Oriented Programming
Polymorphism- It means many forms.
It is the ability to take more than one form. Polymorphism allows us to perform a
single action in different ways.
Data Members And Member Functions
• Data members are the data variables.

• Member functions are the functions used to affect these variables and together these data members and member
functions defines the properties and behavior of the objects in a Class.
Advantages of OOPs

There are various advantages of object-oriented programming.


❑ OOPs provide reusability to the code and extend the use of existing classes.
❑ In OOPs, it is easy to maintain code as there are classes and objects, which helps in making it
easy to maintain rather than restructuring.
❑ It also helps in data hiding, keeping the data and information safe from leaking.
❑ Object-oriented programming is easy to implement.
Simple String Program
#include<iostream>
using namespace std;
Int main()
{
cout<<“Hello word”<<endl;
return 0;
}
Simple Integer Program
#include<iostream>
using namespace std;

int main()
{
int var1, var2;
Int var1 = 20;
var2 = var1 + 10 ;
cout << "var2 is = ";
cout << var2<<endl;
return 0;

}
Simple Character Program
#include<iostream>
using namespace std;
int main()
{
char charvar1 = 'A';
char chrvar2 = '\t’;
//charvar1 = 'B';
cout << charvar1;
cout << '\n';
return 0;
}
Simple Float Program

#include <iostream>
using namespace std;
int main()
{

cout <<("the output is = " );


cout << (3.5 + 4 + 5) << endl;

return 0;
}

You might also like