Getting Started with CPP(C++) Programming Language

Getting Started with CPP(C++) Programming Language


What is C++ (programming language)?

C++ is a general-purpose object-oriented programming (OOP) language, developed by Bjarne Stroustrup, and is an extension of the C language. Being extension of C language, C++ therefore allows us to write code in both “C style” and “object-oriented style”.Some times C++ is also called a hybrid language. C++ is considered as middle level (intermediate-level) programming language as it posses both high level and low level features.
C++ is one of the top 5 popular programming language in present time. Most of the operating system, system drivers, games and other system applications are written in C++ as their core language. The reason behind it is that C++ is more machine friendly than the other languages. This makes C++ popular these days.

Features of C++

It is good to know about the features of any thing before getting into it. Knowing about the features of any thing helps us to learn that thing clearly and efficiently. So before getting started with CPP (C++) Programming language, let’s look over some of its important features that makes it different from other. Following are some of important features of C++:
  • Speed:  Since C++ is an intermediate-level language, so it is more machine friendly than the programming languages like JAVA, Python etc. Due to this fact it is faster than those programming language.
  • Simple: C++ can be considered simple programming language in the sense that it allows structured programming, contains large number of libraries,data types and so on.
  • Machine Independent: C++ is a machine independent language. It means to say that we need not to write separate codes for separate machines. Program written on one machine can be used for other machines.
  • Structured Programming: C++ supports structured programming i.e. we can break a complex code into several sets of simpler bunch of codes called functions. This makes our code easy to understand, modify and debug.
  • Object Oriented: We already discussed that C++ is an object oriented programming language, so c++ must show object oriented features like making classes and their objects. Objects can be regarded as user defined data types and their respective classes can be considered as their definition.
  • Polymorphism: C++ supports polymorphism. It is one of the strong features of an object oriented programming language that allows programmer to use same identity(i.e. name) for multiple entities(here entities refers to objects,functions etc.) having similar logic. However there are certain rules for polymorphism. we shall cover those in upcoming articles.
  • Inheritance: As the literal meaning of the word inheritance suggests, we can inherit the characters (data types and functions) of one class into the another class. The from where the characters are derived is called base class and the class in which the character is derived is called derived class.
  • Exception Handling:  This feature allows us to handle any kind run time exceptions or errors as our wish. If the run time errors or exceptions are not handled then they may change the logic of our program and in some cases it may cause termination of our program in middle of execution.
  • others….

First C++ Program

These days there is a common trend of writing first code as printing “Hello world!!” in any programming language as the beginning point. Let us do the same thing. The C++ code for displaying
“Hello world!!” is as given below:
#include <iostream>
using namespace std;
int main()
    cout<<“Hello World!“;
    return 0;
This Program prints Hello World! in the screen.

Now Let’s Understand the above code in detail:
  • #include <iostream>:

 This statement includes the header file into the current program so that you are able to use the predefined functions included within them.  you can also create your own header files and include them in your program using the #include. We shall discuss it in detail later.

  • What is iostream?

iostream is a header file. It is a standard C++ input/output library file. We neednot to built it, it comes packaged with the compiler/IDE and contain procedures to get the information from the user and print same or added information to a file, screen or any other media.

  • #include: 
The #include is the keyword used to include the libraries or header files into our current program.
  • What’s a namespace?
It’s a region where your code resides. It limits or expands the scope of statements of your code to one or more files.
  • What is using namespace std;?
The functions like cout:(for printing information in screen) and cin:(for taking input from user) are defined within the namespace std. By using using namespace std;, actually we are extending the scopes for cout and cin over our whole code.
If we hadn’t used the namespace, we’d have written std::cout instead of cout. This tells the compiler that every cout is actually std::cout.
  • What is std?
std is a standard namespace used in C++.
  • What is purpose of using Semicolon ”;”?
The semicolon is a terminal. It terminates a statement. When missed or incorrectly used, it will cause a error.
  • What is int main() { }
As the name suggests, it is the main function of the program. The code inside { } is called the body and is executed first when you run your C++ program.
It is one code that is mandatory in a C++ program. If you just have this line of code alone, your program will be valid.
cout << “Hello World!”;
This statement prints “Hello World!” in the output screen.
  • What is a stream?
Stream is basically a sequence of objects, usually bytes. It can describe files, input/output terminal, sockets, etc.
  • What is <<?
<< is the insertion operator used to write formatted data into the stream.
  • return 0;
This statement returns 0 ‘zero’.
This is called a return statement. It isn’t mandatory to return anything from the main() function but is rather a convention. If not return, the compiler returns a status automatically.

Leave a Reply

Insert math as
Additional settings
Formula color
Text color
Type math using LaTeX
Nothing to preview
%d bloggers like this: