Hello friends, in this post today, we will learn about what are the Basic Concepts in c++ programming and also learn what are the major pillar of object oriented programming used in c++ programming language. so let's start....
There are various concepts present in OOP to make it more powerful, secure, reliable and easy.
![]() |
Basic concepts of c++ |
Object
- Objects is a run time entity.
- All objects are instance of a class.
- An object means anything from real world like as person, computer, bench etc...
- Every object has at least one unique identity.
- An object is a component of a program that knows how to interact with other pieces of the program.
- An object is the variable of the type class.
- Objects occupy space in memory and all objects share same set of data items which are defined when class is created.
- The variable of type class is called an object which has a physical existence and also known as an instance of class.
- For example, If water is class then river is object.
Class
- A class is a template that specifies the attributes and behavior of things or objects.
- A Class is a means to achieve encapsulation.
- A class is a user defined new data type like Student, Book, Account detail etc.
- A class is a blueprint or prototype from which objects are created.
- A class is the implementation of an abstract data type (ADT).
- It defines attributes and methods.
- Class is a description of object’s property set and set of operations.
- For creating a new class we use class keyword.
- The body of class must be enclosed within curly braces({}) and terminated by a semicolon(;).
Data Abstraction
• Just represent essential features without including the background details.
• They encapsulate all the essential properties of the objects that are to be created.
• The attributes are sometimes called ‘Data members’ because they hold information.
• The functions that operate on these data are sometimes called ‘methods’ or ‘member functions’.
• It is used to implement in class to provide data security.
Encapsulation
• Wrapping up of a data and functions into single unit is known as encapsulation.
• In other words:-
”act of combining properties and method related to the same object”.
• In C++ the data is not accessible to the outside world.
• Only those functions can access it which is wrapped together within single unit.
Inheritance
• Inheritance is the process, by which class can acquire the properties and methods of another class.
• The mechanism of deriving a new class from an old class is called inheritance.
• The new class is called derived class or child class and old class is called base class or parent class.
• The derived class may have all the features of the base class.
• Programmer can add new features to the derived class.
• For example, Student is a base class and Result is derived class.
Polymorphism
• A Greek word Polymorphism means the ability to take more than one form.
• Polymorphism allows a single name to be used for more than one related purpose.
Types of Polymorphism :
Polymorphism is of two types which are given below :
1. Compile time polymorphism.
2. Run time polymorphism.
• The concept of polymorphism is characterized by the idea of ‘one interface, multiple methods’,
• That means using a generic interface for a group of related activities.
• The advantage of polymorphism is that it helps to reduce complexity by allowing one interface to specify a general class of action’. It is the compiler’s job to select the specific action as it applies to each situation.
• It means ability of operators and functions to act differently in different situations.
Example:
int total(int, int);
int total(int, int, float);
Static Binding
• Static Binding defines the properties of the variables at compile time. Therefore they can’t be changed.
Dynamic Binding
• Dynamic Binding means linking of procedure call to the code to be executed in response to the call.
• It is also known as late binding, because It will not bind the code until the time of call at run time. In other words properties of the variables are determined at runtimes.
• It is associated with polymorphism and inheritance.
Message Passing
• A program contains set of object that communicates with each other.
• Basic steps to communicate
1. Creating classes that define objects and their behavior.
2. Creating objects from class definition
3. Establishing communication among objects.
• Message passing involves the object name, function name and the information to be sent. Example: employee.salary(name);
In above statement employee is an object. salary is message, and name is information to be sent.
Modularity
• The act of partitioning a complex program into simpler fragments called modules is called as modularity.
•It reduces the complexity to some degree and
•It creates a number of well defined boundaries within the program .
Data Hiding
Data hiding hides the data from external access by the user. In OOP language we have special keywords like private, public, protected access specifiers, which hides the data.
I hope that whatever information I have given in this post today, you have liked it and you have understood it.so keep learning and wait for the next post that will help you to increase your knowledge with the something new information.
Thank you so much for reading. And take care about yourself and your family.
Comments
Post a Comment