Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Sunday, June 13, 2021

OPPs Concept in C++

Classes and Objects: Everything in C++ is associated with classes and object along with its attributes (variables) and functions.

OPPs Concept in C++ | welcome2protec
OPPs Concept in C++ | welcome2protec

OOPs Concept in C++:

C++ programming is the object oriented programming which focuses more on real world entity. For example, chair, car, pen, mobile, laptop etc. In other words, object is an entity that has state and behavior. Here, state means data and behavior means functionality. Object is a runtime entity, as it is created at run time.

Let’s take an example of the Coaching club. The club(consider as class) has many items (consider as variable) and many training facilities(assume this as methods or functions). Now suppose an outside people wants to get access to the club’s resources and its facilities the firstly they must enroll and become the member of the club ( i.e. make an object to access the club’s resources). This is how object oriented paradigm work.

❯ All the variables and the methods are bind inside a class and object are required to get access to the particular method’s and variables.


Advantage of OPP:

Object oriented programming is a way of solving complex problem by breaking them into smaller one using object. Before programs were written in procedural language , they were nothing but a long list of instructions. On the other hand OPPs is all about creating objects that can interact with each other, this make it easier to develop programs in OOP.

  • OPPs is faster and eaiser to execute.
  • OPPs provide the clear structure of program.
  • Re-usability: "Write once and use it multiple times" you can achive this by using class.
  • Security: Using data hiding and abstraction only necessary data will be provide thus maintains the security of data.
  • OPPs helps to kepp the C++ code DRY "Don't Reoeat Yourself" and make the code easier to maintain, modify, and debug.

DRY "Don't Repeat Yourself" principial is about reducing the repetition of code.


Here is the list of basic concept of object oriented programming (OOP) language is:


Classes and Objects in C++:

C++ is an object oriented programming languages. Everything in C++ is associated with classes and object along with its attributes (variables) and functions.

Class: A class is like a blueprint of data members (Variables) and functions (Methods), it helps us to group data members and methods using available access specifiers. Let's have a look at the below example:

Classes & Objects | welcome2protec
Classes & Objects | welcome2protec

Object: Object is a real world entity, for example, chair, car, pen, mobile, laptop etc. In other words, object is an entity that has state and behavior. Here, state means data (like variabls) and behavior means functionality (functions). In real life a car is an object. The car has attributes, such as weight, color, price speed, and methods like drive(), gearChange(), slowDown(), and brake() etc.


Abstraction:

Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation. For example: In an ATM transection we supply only the required information like password and how much money we need that's it. But what happen in the background for doing this transection we don't know. This is known as abstraction.


Encapsulation:

Encapsulation is process of combining data and function into a singal unit like a capsule, a capsule which is mixed of several medicines. In general, encapsulation is a process of wrapping similar code in one place.

Advantage of Encapsulation:

Encapsulation protects an object from unwanted access by clients. Encapsulation allows access to a level without revealing the complex details below that level. It reduces human errors. Simplifies the maintenance of the application. Makes the application easier to understand.


Inheritance:

It allows us to create a new class (derived class) from an existing class (base class). The derived class inherits the features from the base class and can have additional features of its own. Simply you can say, it allows the child class to acquire the properties (data members) and functionalities (functions) of parent calss.

For example:

class Animal{
  eat();  	
  sleep(); 
}; 
class Dog : public Animal{
 bark()
};
  
int main(void){
 Dog obj;
}

Now this object obj can use the properties of parent class.


Polymorphism:

A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person posses different behavior in different situations. This is called polymorphism. Function overloading (same function name but different parameter) and operator overloading are example of polymorphism.


Dynamic binding:

Method Overriding is a perfect example of dynamic binding as in overriding both parent and child classes have same method and in this case the type of the object determines which method is to be executed. The type of object is determined at the run time so this is known as dynamic binding.


Message Parsing:

Parser is a compiler that is used to break the data into smaller elements coming from lexical analysis phase. A parser takes input in the form of sequence of tokens and produces output in the form of parse tree. Parsing is of two types: top down parsing and bottom up parsing.








Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Help others by sharing this page.

Ahmad Irshad

Author & Editor

I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us