Forum

Major Features of C++

This thread contains 1 reply, has 2 voices, and was last updated by  Test 8 months, 2 weeks ago.

  • Author Replies
  • #52870

    What are the Major Features of C++?


  •  Test
    #52872

    This primarily preferred standpoint of C++ is, it is an object-oriented programming language. It pursues the idea of oops like polymorphism, inheritance, encapsulation, abstraction.

    Major Features of C++ are as follows: –

    1) Class: Class is a blueprint of data and functions or methods. Class does not take any space.

    A class in C++ contains, following properties;

    (i) Data Member
    (ii) Method
    (iii) Constructor
    (iv) Block
    (v) Class and Interface

    2) Object: Objects are basic run-time entities in an object-oriented system, objects are instances of a class these are defined user-defined data types.

    An Object in C++ has three characteristics:

    (i) State
    (ii) Behavior
    (iii) Identity

    3) Encapsulation: Wrapping up(combining) of data and functions into a single unit is known as encapsulation. The data is not accessible to the outside world and only those functions which are wrapping in the class can access it. This insulation of the data from direct access by the program is called data hiding or information hiding.

    Example of Encapsulation in C++

    #include<iostream.h>
    #include<conio.h>

    class sum
    {
    private: int x,y,z;

    public:
    void add()
    {
    clrscr();
    cout<<“Enter any two numbers: “;
    cin>>x>>y;
    z=x+y;
    cout<<“Sum: “<<z;
    }
    };
    void main()
    {
    sum s;
    s.add();
    getch();
    }
    Output
    Enter any two number:
    1
    2
    Sum: 3

    4) Data abstraction:  Abstraction is the concept of exposing only the required essential characteristics and behavior with respect to a context.

    Hiding of data is known as data abstraction. In an object-oriented programming language, this is implemented automatically while writing the code in the form of class and object.

    Example of Abstraction in C++

    #include<iostream.h>
    #include<conio.h>

    class sum
    {
    // hidden data from outside world
    private: int x,y,z;

    public:
    void add()
    {
    clrscr();
    cout<<“Enter any two numbers: “;
    cin>>x>>y;
    z=x+y;
    cout<<“Sum: “<<z;
    }
    };
    void main()
    {
    sum s;
    s.add();
    getch();
    }
    Output
    Enter any two number:
    2
    3
    Sum: 5

    Note:
    i) Data abstraction can be used to provide security for the data from the unauthorized methods.
    ii) In C++ language data abstraction can be achieved by using class.

    5) Inheritance: The process of obtaining the data members and methods from one class to another class is known as inheritance. It is one of the fundamental features of object-oriented programming.

    Syntax
    class subclass_name : superclass_name
    {
    // data members
    // methods
    }

    6) Polymorphism: Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation.

    7) Dynamic Binding: In dynamic binding, the code to be executed in response to the function call is decided at runtime. C++ has virtual functions to support this.

    8) Message Passing: Objects communicate with one another by sending and receiving information to each other. A message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired results. Message passing involves specifying the name of the object, the name of the function and the information to be sent.


You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Contact Us

Working Hours

  • Monday9:00 AM – 9:00 PM
  • Tuesday9:00 AM – 9:00 PM
  • Wednesday9:00 AM – 9:00 PM
  • Thursday9:00 AM – 9:00 PM
  • Friday9:00 AM – 9:00 PM
  • Saturday9:00 AM – 9:00 PM
  • SundayClosed
Copyright 2016-2019 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

Register your Interest