Ticker

6/recent/ticker-posts

BASIC CONCEPT IN OOPs - C++

Some important concept in oops are :

  1. Objects 
  2. Classes 
  3. Data abstraction & Encapsulation. 
  4. Inheritance 
  5. Dynamic binding. 
  6. Message 

1) Object :- 

  • Object are the basic run-time entities in an object-oriented system. 
  • They may represent a person, a place a bank account, a table of data or any item that the program has to handle. 
  • Programming problem is analysed in terms of objects and the nature of communication between them. 
  • Objects take up space in the memory & have an associated address like structure in c. 
  • When a program executes, the object interacts by sending messages to one another. Ex. If there are two objects "customer" and "account" then the customer object may send a message to account object requesting for the bank balance. Thus each object contains data, and code to manipulate the data.
Student Object.
 Student Object.

2) Classes :-

  • The entire set of data and code of an object can be made a user-defined data type with the help of a class. Objects are actually variable of the type class. 
  • Once a class has been defined, we can create any number of objects belonging to that class. Thus a class is collection of objects of similar type. 
  • Classes are user defined data types and behaves like the built in type of a programming language. 
  • The syntax for defining class is class 
        class-name { 

            ---------------- 

            ---------------- 

        }

3) Data abstraction and Encapsulation :-

  • The wrapping up of data and functions into a single unit called class is known as encapsulation. 
  • The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. 
  • These functions provide the interface between the objects data and the program. This insulation of the data from direct access by the program is called data hiding or information hiding. 
  • Abstraction refers to the act of representing essential features without including the background details or explanations. 
  • Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and coast, and functions to operate on these attributes.

4) Inheritance :-

  • Inheritance is the process by which object of one class acquire the properties of objects of another class. 
  • In OOPs, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. 
  • This is possible by deriving a new class from the existing one. The new class will have combined features of both the classes.

5. Polymorphism :-

  • Polymorphism is important oops concept. It means ability to take more than one form. 
  • In polymorphism an operations may shows different behavior in different instances. The behavior depends upon the type of data used in the operation. For Ex- Operation of addition for two numbers, will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation. 
  • The process of making an operator to show different behavior in different instance is called as operator overloading. C++ support operator overloading.

Polymorphism

Polymorphism 

The above figure shows concept of function overloading. Function overloading means using a single function name to perform different types of tasks.

 5) Dynamic Binding 

  • Binding referes to the linking of a procedure call to the code to be executed in response to the call. 
  • Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time. 

6) Message Passing 

  • OOPs consist of a set of objects that communicate with each other. 
  • Message passing involves following steps
    • Creating classes that define objects and their behavior 
    • Creating objects from class definitions and 
    • Establishing communication among objects
  • A message for an object is a request for execution of a procedure & therefore will invoke a function in the receiving object that generates the desired result.
Message passing involves specifying the name of the object, the name of the function i.e. message and the information to be sent.

message
message

ALSO SEARCH :-

"oops concepts in c++ with examples"

"c++ basic concepts"

"object-oriented programming"

"basic concepts of oops in C++"

"benefits of oop in c++"