C++ Programming Language

unnamed (1)
Computer Language Technology

C++ Programming Language

Introduction to C++

C++ programming language was designed to provide enhancement of C language, include an object-oriented approach. C++ language was designed by Bjarne Stroustrup, in order to create high-level applications. C++ is also a cross-platform language, as we know it is based on an object-oriented approach so provides us greater reusability of code, secure, scalable, and lower development cost as well.

What is C++ Programming Language?

It is one of the most common languages used in the world which helps us to create the embedded system, used in most of the operating system, and in GUI (graphical user interface). By the use of this language, we can control the memory resources of the system in a managed manner. Apart from object-oriented, it provides good support for different ways of programming which include functional and procedural, etc, due to this adaptive, it is very flexible to use.

Examples

#include <iostream>

int main() {

    std::cout << “Demo program for C++ programming laguage !! \n”;

    int mynum1 = 100;    

    int mynum2 = 23;    

    int mynum3 = 14;    

    int mynum4 = 15;    

    int mynum5 = 7;    

    std::cout << “calculate the divisor of five \n”;

            if (mynum1 % 5 == 0)    

            {    

                std::cout<<“number is divisor of five \n”;    

            } 

            if (mynum2 % 2 == 0)    

            {    

                std::cout<<“number is divisor of two \n”;    

            } 

            if (mynum3 % 3 == 0)    

            {    

                std::cout<<“number is divisor of three “;    

            } 

            if (mynum4 % 4 == 0)    

            {    

                std::cout<<“number is divisor of four “;    

            } 

   return 0;

}

Output:

C++ Programming Examples 1

How C++ Programming makes working easy?

It supports several ways of programming which include OOPS, functional and procedural. It supports the concept of inheritance, polymorphism, encryption, and so on. These basic concepts provide us security, scalability, reusability of properties, etc. In procedural programming approaches, we create functions or procedural that is used to perform the action on the data. But in the object-oriented programing approach, we create the object of the class and this class contains various functions, class member,s, and so on. We have so many advantages of using the OOPs approach which is as follows;

1) By using OOPS we can reuse our code, because of its basic concept available.

2) It is fast to execute as well.

3) It reduces the development time, provides a clear structure of the class and program.

4) To use any method of the class we can create objects to access them.

The idea for C++ programming language revolves around classes and objects, classes are the entity for object and object is the instance of the class. Let’s take an example to understand how it reduces our development effort see below;

Suppose we have to represent different types of fruits we have so many variety of fruits available with some common property and some different property. To represent this we are going to create a class that will represent fruits, every fruit has color and taste with it which is unique. So below we can represent this structure as like;

class Fruit{}

class Apple{}

class Banana{}

class Orange{}

1) Inheritance: Inheritance in C++ represents the parent and child relation. In which we can use all the functionality and property of the parent class from the child class. In this we have two things;

a) base class:  Also known as the parent class

b) derived class: This class will be derived from using another class.

The concept of inheritance provides us reusability, optimized code, etc.

2) Encapsulation: By the use of this we can secure or hide our data from the outside world. With this they cannot modify our data, hence will be hidden from the user. To achieve this we have to declare all our member variables as private inside the class.

3) Polymorphism: By the use of polymorphism we can use methods that will perform a different task. We can say that the same method with different implementations specific to the class. Thus provide us reusability of the attribute and methods of the class.

This all makes our development easy.

What is C++ Programming used for?

Today we have so much software that is based on the C++ language. It is used in different real-world application such as :

1) Operating system: It is majorly used in today’s operating system because it is a strongly typed language. Also, it provides us with so many system-level functions that help us to write low-level programs for the operating system.

Some of the operating system as 

a) Microsoft windows

b) Apple

2) Brower’s: To reduce the timing of web pages most often rendering engines are written in C++ language because if the web page takes more time in rendering it will impact the performance. So while writing browser, rendering engines written in c++ for faster execution.

Some of the browsers as:

a) Google

b) Firefox

c) thunderbird

3) Banking applications: Banking applications require security and concurrency at a high level. Also, it provides us multithreading and high performance which is the most required factor for any banking application.

4) Enterprise software: C++ also used in developing enterprise software.

5) Database software: To store data we required database for this, we have two most popular relational database which is written in c++ language follows as :

a) Postgres

b) MySQL

6) Gaming system: By the use of c++ language we can easily control the resources and memory of the system, manipulate resources and make it fast because of these features c++ makes a good choice for the gaming system as well.

7) Used to develop desktop and graphical user interface.

Pros

1) support procedural or functional programming support.

2) Provide support for multithreading, concurrency.

3) Control over the system resources.

4) Fats execution, better performance, and scalable.

Cons

1) As it is strongly typed language so we need to be extra careful while writing code.

2) No security.

3) Platform-specific application only.

4) It does not support garbage collection.

Summary

  • C++ is mainly used for embedded applications, it is an extension to C programming language. Which comes up with the concept of object-oriented programming language which reduced our work.
  • We can use c++ as per the requirement of our application.
  • C language is by far the most popular and widely used program to develop different popular operating systems like UNIX and LINUX which are usually written in C.
  • The C program enables programs to sustain portability code, maintain performance, and minimize CPU limitations, such as memory and system performance time, etc.
  • It is one of the most common languages used in the world which helps us to create the embedded system, used in most operating systems.
  • Today we have so much software that is based on the C++ language. It is used in the different real-world application
  • C language supports procedural or functional programming and provides support for multithreading, concurrency.

Leave your thought here

Hey, wait!

Before you go, let us offer you a 10% discount coupon for your purchase.