Intro
The C++ programming language based on C language was designed & implemented by Bjarne Stroustrup. C++ is an object-oriented high-level programming language.
Get Started
Before you start to write your first C++ code, you needed to install an IDE(Intergrated Development Environment) for write and compile C++ code. You may install any IDE which supports C++, but we will use Microsoft Visual Studio for illustration.
You may get lastest Microsoft Visual Studio at https://visualstudio.microsoft.com
Step to install Visual Studio
- Install Visual Studio Installer
- Open Visual Studio Installer
- Select "Desktop development with C++" workload
- Click Install button
Create first C++ program
- Create a new project
- Select Empty Project & click Next
- Pick a name for your first C++ project & click Next
- Right click the "Source Files" in Solution Explorer --> Add --> New Item --> C++ Files --> Add
- Write the following code in Visual Studio & save (Don't need to understand the code in this chapter, it will be discuss in later chapters.)
- Click Run button to execute our first C++ program. Tada, this will be how our first C++ program looked like. We had finished the set up of C++ develop environment.
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}
FAQ
Q1: Unable to install visual studio 2022: couldn't install microsoft.visualcpp.redist.14.latest
A1: Maybe you have older version of C++ Redistribution installed, so you need to update it.
Steps:
- Download new version installation file: https://docs.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170 [Download both X86 and X64 version]
- Install both of it
- Restart PC and try to install visual studio 2022 again