Skip to main content

Basic Concepts in c++ programming

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....

Basic concepts in c++, basic concepts of c++




There are various concepts present in OOP to make it more powerful, secure, reliable and easy.

Basic concepts in c++,Basic concepts of c++
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

Popular posts from this blog

Constructor in c++

Hello friends, in this post today, we learn about  what is constructor in c++ and types of constructor . so lets start... Constructor in c++ Constructor:-   A constructor is a “special” member function which initializes the objects of class.  Constructor is used to solve problem of initialization. Properties of constructor:- Constructors are used to construct the object of the class. Constructor name must be same as class name. Constructor is invoked automatically when objects of the class are created. The constructors are always declared in the public section. If declared in the private section then objects are can only be created inside the member functions but serve no purpose. It must be an instance member function , that is, it can never be static. Constructors  do not have any return type not even void so they cannot return any value. Constructor can also be overloaded. Constructors cannot be inherited, but they can be called from the constructors of...

Function with Default arguments in c++

Hello friends, i n this post today, we learn about   Function with Default arguments in c++ .  so lets start... Function with default arguments  Function with default arguments:- In C ++ it is possible for a function not to specify all its arguments. Some of the arguments  may be specified their default values at the time of declaring the function.   Default values are specified when the function is declared. We must add default arguments from right to left. We cannot provide a default value to a particular argument in the middle of an argument list. Default arguments are useful in situations where some arguments always have the same value. For Example, passing marks. In a function with default argument, if one argument is default, all successive arguments  must be default. We cannot provide default values in the middle of the arguments or towards  l eft side. We provide few examples: 1. void fun(int x, int y = 20, int z=35); (valid) 2. void fun(int x,...

Pure virtual function in c++

Hello friends, i n this post today, we learn about what is pure virtual  function in c++ and how to use pure virtual function  in c++ .  so lets start... Pure virtual function in c++ Pure virtual function:- A pure virtual function is a function which has its body set to 0 i.e., the pure virtual function  does not have any body. A pure virtual function means ‘do nothing’ function. A function declared in a way: Syntax:- virtual void display() = 0;  is known as pure virtual function. Here = 0 does not mean that function show is equal  to 0. It simply means that the virtual function show has no body.  The pure virtual function act  as an interface and any class which inherits the class in which pure virtual function is present,  has to provide the implementation for the function show. We can say empty function. A pure virtual function has no definition relative to the base class. Programmers have to redefine pure virtual function in derived clas...