C++
Programming Language

C++

A popular general purpose language.

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

  1. Install Visual Studio Installer
  2. Open Visual Studio Installer
  3. Select "Desktop development with C++" workload
  4. Click Install button

Create first C++ program

  1. Create a new project
  2. Select Empty Project & click Next
  3. Pick a name for your first C++ project & click Next
  4. Right click the "Source Files" in Solution Explorer --> Add --> New Item --> C++ Files --> Add
  5. 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.)
  6. #include <iostream>
    using namespace std;
    
    int main() {
        cout << "Hello World!";
        return 0;
    }

  7. Click Run button to execute our first C++ program.
  8. Tada, this will be how our first C++ program looked like. We had finished the set up of C++ develop environment.

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:

  1. 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]
  2. Install both of it
  3. Restart PC and try to install visual studio 2022 again


©2022 17Hieng