Why Learn C++?
Why learns C++
C++ is an object-oriented programming language which means that the main focus is on objects and manipulations around these objects. When speed is a critical metric, C++ is the most preferred choice. Unlike other programming languages where no compilation is required, every C++ code has to be first compiled to a low-level language and then executed. The C++ Standard Template Library (STL) has many functions available to help write code quickly.
C++ is a fast and strongly-typed programming language which makes it an ideal choice for developing operating systems. Web browsers need to be fast in execution as people do not like to wait for their web pages to be loaded. This is why most browsers are developed in C++ for rendering purposes. Mozilla Firefox is completely developed from C++. Google applications like Chrome and Google File System are partly written in C++.Various embedded systems that require the program to be closer to hardware such as smartwatches, medical equipment systems, etc., are developed in C++.Because C++ is one of the fastest programming languages, it is widely used for programming routers, telephone switches, and space probes.
Modern C++ and the C++ Standard
Modern C++ and the C++ standard
Modern C++ differs from old style C++ because older C++ use to focus more on OOP (object-oriented programming) while modern C++ uses a mixture of various programming styles
C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in December 2020 as ISO/IEC 14882:2020 (informally known as C++20).
How does all this work?
How do all this work
Let’s understand what happens behind the scenes. Here’s a simple breakdown of the process. A compiler converts source code (which you've written) to an object code the machine can read. This machine-readable code is usually made up of zeroes and ones since it's in binary form. Now the compiler can run the program as an executable file.
In reality, this process is much more complex.
Installation and Setup Overview
Installation and Setup Overview
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.
3) 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.
4) 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.
5) 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“.
6) Now, open up the properties of your windows machine and click on the advanced settings button.
7) Click on the environment variable button.
8) Now, select the path variable by simply clicking on it.
9) Click on the edit button to add the environment variables.
10) Open Up the command prompt, type and press enter
Installing the C++ Compiler on Windows
Installing the C++ Compiler on Windows
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.
3) 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.
4) 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.
5) 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“.
6) Now, open up the properties of your windows machine and click on the advanced settings button.
7) Click on the environment variable button.
8) Now, select the path variable by simply clicking on it.
9) Click on the edit button to add the environment variables.
10) Open Up the command prompt, type and press enter
Installing CodeLite on Windows
Installing CodeLite on Windows
Download CodeLite from codelite.org
Select “Download CodeLite” link.
To download the free software, select “No thanks, just take me to the download page”.
Select the link for download 2.
Install CodeLite after downloading the software
Step 1: double click on the downloaded software •
Step 2: Select the destination location
Step 3: Perform Full installation: select all the components
Step 4: installing…
Step 4 (continued): Search for Compilers on your computer CodeLite installation compiler
Configuring CodeLite on Windows
Configuring CodeLite on Windows
We will show all the steps below of how to set up CodeLite to be able to execute C++ programs.
So the first step in the process is to create a New Workspace.
The Workspace is kind of like the folder that holds all the projects folders of a given coding program.
So you have your general workspace and then you have all the projects folders in that workspace that you will use for a coding program.
So go to the Menu bar where you see 'Workspace' and click on the button; a drop-down menu will appear. There you click on 'New Workspace'.
This is shown below.
So now a new window will pop up. Here in this window, you have to specify the workspace path (which folder the workspace will be in) and the name of the workspace.
Below, I save my workspace in the C++programs folder and as the name, Workspace1.
Installing the C++ Compiler on Mac OSX
Installing the C++ Compiler on Mac OSX
First download VS Code on your device.
You can also Download M1 specific Visual Studio Code(i.e. Visual Studio code- Insiders)
After downloading Visual Studio Code or Visual Studio Code Insiders open it and go to extensions. There is a search tab, just type c++ then click on 1 recommendation and install it. Another extension you have to download is code runner.
During this process, users can come across 2 different types of issues. So let’s discuss what they are and how to resolve them.
Problem 1: After downloading all extensions on VS Code not able to work on CPP.
Follow the below steps to resolve the same issue:
- Step 1: Open your terminal and run the below command:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/ Homebrew/install/master/install.sh)"
- Step 2: Now after the completion of the previous command type:
arch -x86_64 brew install mingw-w64
Problem 2: #include<bits/stdc++.h> is not found.
If you want to more about the system header file click here. Follow the below steps to resolve the issue:
- Step 1: Open terminal using command+space and type terminal.
- Step 2: Now move to the below-given path :