WHAT IS C++ PROGRAMMING LANGUAGE
C++ (said C plus plus) is an object-oriented computer language created by notable computer scientist Bjorne Stroustrop as part of the evolution of the C family of languages. It was developed as a cross-platform improvement of C to provide developers with a higher degree of control over memory and system resources.
Some call C++ “C with classes” because it introduces object-oriented programming principles, including the use of defined classes, to the C programming language framework. Over time, C++ has remained a very useful language not only in computer programming itself, but in teaching new programmers about how object-oriented programming works. However, it does not support only object-oriented, but also procedural and functional. Thanks to its high flexibility and scalability, C++ can be used to develop a broad range of software, applications, browsers, Graphical User Interfaces (GUIs), operating systems, and games.
Today C++ is still very appreciated for its notable portability which allows developers to create programs that can run on different operating systems or platforms very easily. Despite being a high-level language, since C++ is still close to C it can be used for low-level manipulation due to its close relation with machine language.
C++ is a cross-platform language that can be used to create high-performance applications.
C++ was developed by Bjarne Stroustrup, as an extension to the C language.
C++ gives programmers a high level of control over system resources and memory.
The language was updated 3 major times in 2011, 2014, and 2017 to C++11, C++14, and C++17.
Bjarne Stroustrup developed C++ at Bell Labs in the early 1980s to merge the best advantages of several other languages. He wanted to put together the quickness of BCPL, the high-level of Simula, and the universality of Dennis Ritchie’s C. He took inspiration from other languages as well, such as Ada, ML, and ALGOL 68, to create a well-structured, general-purpose language that could compile nearly all C programs without changing their source code. C++ is so flexible that is often nicknamed the “Swiss Pocket Knife of Programming Languages” (although this nickname is shared by Python as well).
C++ and Object-Oriented Programming
When C++ was new, object-oriented programming was just coming on the scene. This revolutionary type of computer programming transformed the coding world with its promise of more sophisticated virtual data types and objects.
In object-oriented programming, an object is a data type that has both data and functions inherent in its design. Prior to the advent of object-oriented programming, programmers typically saw a codebase as composed of individual command line instructions. The identification of objects with data and functions built in led to a new way of packaging and automating code work.
The C++ Stack
For an excellent example of object-oriented programming in C++, one of the most notable and useful features of the language was the C++ stack.
The C++ stack is a class in C++ that has the following characteristics – it is a virtual last in first out sequential storage container that has a defined set of elements. The functions ‘push’ and ‘pop’ either push a new item into the bottom of the stack or pop the first available item from the top of the stack.
Programmers have utilized the C++ stack in many different ways to achieve goals involving variable evaluation and functional operations within a codebase.
The language also applies principles of encapsulation, which identifies usage models, and inheritance, where one class can inherit certain attributes or properties from another.
Why Use C++
C++ is one of the world’s most popular programming languages.
C++ can be found in today’s operating systems, Graphical User Interfaces, and embedded systems.
C++ is an object-oriented programming language which gives a clear structure to programs and allows code to be reused, lowering development costs.
C++ is portable and can be used to develop applications that can be adapted to multiple platforms.
C++ is fun and easy to learn!
As C++ is close to c# and java, it makes it easy for programmers to switch to C++ or vice versa
Features of C++
Here are some of the remarkable features of C++ language:
1. OOP (Object-Oriented Programming)
C++ is an object-oriented language, unlike C which is a procedural language. This is one of the most important features of C++. It employs the use of objects while programming. These objects help you implement real-time problems based on data abstraction, data encapsulation, data hiding, and polymorphism. We have briefly discussed all the 5 main concepts of object-oriented programming.
The OOP concepts are:
- Data abstraction: Data abstraction is an act of representing the important features of data without including the background details or the method applied to obtain it.
- Data encapsulation: Data encapsulation is nothing but a process to implement data abstraction by wrapping up the data and functions into an exclusive block.
- Inheritance: The term inheritance refers to transferring the properties of the parent class to the child class. We can implement the basic idea of inheritance by creating more than one class, which we formally refer to as derived classes by linking them with what we call the base class. This concept reduces the redundancy of the program and makes it easy to transfer/copy the properties of one class to another
- Data hiding: Data hiding refers to protecting data from unauthorized access. It is basically responsible for securing the data. It is important to note that data encapsulation is different from data hiding as encapsulation mainly focuses on shifting the focus on important data than explaining its complex nature.
- Polymorphism: The word poly means ‘many’ and morphism means ‘forms’. Clearly, polymorphism refers to displaying that data in more than one form.
2. Platform or Machine Independent/ Portable
Although C++ is not platform-independent as compiled programs on one operating system won’t run on another operating system
But in another term, portability refers to using the same piece of code in varied environments.
Let us understand this C++ feature with the help of an example. Suppose you write a piece of code to find the name, age, and salary of an employee in Microsoft Windows and for some apparent reason you want to switch your operating system to LINUX. This code will work in a similar fashion as it did in Windows.
When we start off with a new language, we expect to understand in-depth. The simple context of C++ gives an appeal to programmers, who are eager to learn a new programming language.
If you are already familiar with C, then you don’t need to worry about facing any trouble while working in C++. The syntax of C++ is almost similar to that of C. Afterall C++ is referred to as “C with classes”.
4. High-level programming language
It is important to note that C++ is a high-level programming language, unlike C which is a mid-level programming language. It makes it easier for the user to work in C++ as a high-level language as we can closely associate it with the human-comprehensible language, that is, English.
After learning C, it is the base language for many other popular programming languages which supports the feature of object-oriented programming. Bjarne Stroustrup found Simula 67, the first object-oriented language ever, lacking simulations and decided to develop C++.
6. Case sensitive
Just like C, it is pretty clear that the C++ programming language treats the uppercase and lowercase characters in a different manner. For instance, the meaning of the keyword ‘cout’ changes if we write it as ‘Cout’ or “COUT”. Other programming languages like HTML and MySQL are not case sensitive.
Unlike Java and Python that are interpreter-based, C++ is a compiler-based language and hence it a relatively much faster than Python and Java.
8. DMA (Dynamic Memory Allocation)
Since C++ supports the use of pointers, it allows us to allocate memory dynamically. We may even use constructors and destructors while working with classes and objects in C++.
9. Existence of Libraries
The C++ programming language offers a library full of in-built functions that make things easy for the programmer. These functions can be accessed by including suitable header files.
As discussed earlier, C++ is compiler-based hence it is much faster than other programming languages like Python and Java that are interpreter-based.
WHAT IS A COMPILER IN COMPUTER PROGRAMMING
A compiler is a program that translates a source program written in some high-level programming language (such as Java) into machine code for some computer architecture (such as the Intel Pentium architecture). The generated machine code can be later executed many times against different data each time.
An interpreter reads an executable source program written in a high-level programming language as well as data for this program, and it runs the program against the data to produce some results. One example is the Unix shell interpreter, which runs operating system commands interactively.
Note that both interpreters and compilers (like any other program) are written in some high-level programming language (which may be different from the language they accept) and they are translated into machine code. For a example, a Java interpreter can be completely written in C, or even Java. The interpreter source program is machine independent since it does not generate machine code. (Note the difference between generate and translated into machine code.) An interpreter is generally slower than a compiler because it processes and interprets each statement in a program as many times as the number of the evaluations of this statement. For example, when a for-loop is interpreted, the statements inside the for-loop body will be analyzed and evaluated on every loop step. Some languages, such as Java and Lisp, come with both an interpreter and a compiler. Java source programs (Java classes with
.java extension) are translated by the
javac compiler into byte-code files (with
.class extension). The Java interpreter, called the Java Virtual Machine (JVM), may actually interpret byte codes directly or may internally compile them to machine code and then execute that code (JIT: just-in-time compilation).
Compilers and interpreters are not the only examples of translators. Here are few more:
|Source Language||Translator||Target Language|
|SQL||database query processor||Query Evaluation Plan|
|Java||javac compiler||Java byte code|
|English text||Natural Language Understanding||semantics (meaning)|
|Regular Expressions||JLex scanner generator||a scanner in Java|
|BNF of a language||CUP parser generator||a parser in Java|
How To Install C++ Compiler On Windows
Step 1: Download MinGW Compiler for Windows 10
1) Firstly we will download the C compiler for our windows machine and for that we’re going to download the “MinGW” compiler. Follow the download link provided below you’ll be redirected official site of MinGW.
2) We will download the self extractable archive for MinGW to make our installation process easy and simple. So simply click on the “MinGW-17.1-without-git.exe” and your download will start.
Step 2: Extract MinGW in Windows 10
1) Once your download gets finished open it from the folder where it has been downloaded and double click on it to start the installation process.
2) Now you’ll be asked to choose the extraction location of the compiler, in the text field type “C:\” and click on the extract button. Extraction of this archive will take some time so keep patience.
Step 3: Setup Environment Variables in Windows 10
1) Next, we will set up the environment variables for accessing GCC in vs code, and to do so, first copy the location of the bin folder from the newly extracted MinGW directory. In our case, it looks like this: “C:\MinGw\bin“.
2) Now, open up the properties of your windows machine and click on the advanced settings button.
3) Click on the environment variable button.
4) Now, select the path variable by simply clicking on it.
5) Click on the edit button to add the environment variables.
6) Now click on the “New” button and paste the location we’ve copied from step 1.5 in this blank field and click ok.
Step 4: Check Installed G++ Version
1) Open Up the command prompt, type g++ –-version and press enter
If you’re able to get similar output to the above image then congrats you’ve successfully installed MinGW Compiler in your windows 10.
Drop your comment