Skip to content

What Is C++? (+An Easy Tutorial for Beginners)

May 10, 2019

No, it’s not the equivalent of a B-.

A brief history on C++: Flashback to 1980, Bjarne Stroustrup developed C++ at Bell Labs originally because he felt there wasn’t a programming language that was ideal for large scale projects. Today, C++ is behind some of the most popular mobile apps and web apps we use every day.

What is C++?

Similar to Python and Java, C++ is a general-purpose, object-oriented programming language. It is an extension of the C programming language, previously called “C with classes.” C++ is considered an intermediate-level programming language because it has a few advanced features and is designed to create big programs that need to run quickly.

C++ is the third most-used programming language. In fact, other programming languages also depend on C++, from Java Virtual Machines (JVMs) and JavaScript interpreters to multiple different browsers and application frameworks.

what c++ looks like

Why you should learn C++

While the C++ programming language is relatively old, it still remains among the most popular programming languages today. C++ offers programmers a lot of control in the development process due to the scalability of the language. The language also allows you to work with the internal hardware of the computer, learning more about memory management and other inner workings. There is also a large community of C++ developers for support and guidance.

However, C++ does have its drawbacks. Because the code is so robust, it’s not necessarily fast or easy to maintain. It’s important to keep in mind that this will absolutely impact the cost of an app because it will take a bigger team longer to build it out. In short, quality takes time.

Download a C++ IDE

In order to follow along with the tutorial, you will need to download C++ integrated development environment (IDE) software. It’s not as scary as it sounds, developers just really like acronyms. An IDE is simply an interface for users to write, organize, and debug code. Be sure to find the right solution as there are different IDE software solutions depending on your device or operating system.

Find the best C++ IDE Software on the market. Explore Now, Free →

Using basic C++ syntax

Syntax refers to the layout of a programming language. Think about the syntax of an email address. If you put the “.” or “@” in the wrong place, it won’t work. Programming languages are no different. You have to follow the syntax rules in order for your program to run. To better understand what the language looks like and how it actually works, let’s write and run our first C++ program.

Note: while I am using Xcode on a Mac and your application might be different, the code will be the same.

Open “Xcode” and select “Create a new Xcode project” from the options listed. Next, click on the “macOS” tab and choose the “Command Line Tool” and hit “Next”.

Xcode menu window

Name your product “HelloWorld” and from the language dropdown menu select “C++”. Notice that the Bundle Identifier automatically generates to “Bridget-Poetker.HelloWorld” from the product name and organization identifier. Click “Next”.

naming your project in Xcode

In the left pane, you’ll see a few files. We’re only interested in the source code, so click on the “main.cpp” file. in the left pane

You’ll notice there is already code generated and provided in the window. Click the play/run icon in the top left corner to build and run the script. You’ll see that there is a “Hello, World!” output in the bottom center window of the application.

C++ hello world tutorial for beginners

I’d like to say that this tutorial is over, but that would be cheating. Let’s get rid of everything on the screen and start over with a simpler version. Simply, highlight and delete. Type “#include <iostream>” to include the input and output stream library. On the next line, type “using namespace std;” to indicate that we will be using the standard C++ namespace. Namespaces help developers avoid duplicate command names.

C++ tutorial for beginners step 1

In C++, the code appears in functions and the initial code runs in the main function. It tells the compiler where to start. On the next line, type “int main()” and hit enter. On the next line, use an open curly brace or “{“. The matching curly brace “}” will automatically appear two lines down.

C++ tutorial for beginners step 2

On the line in-between the braces, type “cout << “Hello World!”;” which tells the console to put out the expression within quotes. The phrase within the quotes is referred to as a string literal. Next, type “return 0;” to end your code technically correct.

C++ tutorial for beginners step 3

Now it’s time to run the C++ program you just wrote. Hit the play/run button in the top left corner again. Xcode will build and run your script to produce the output "Hello World!"

C++ tutorial for beginners output

Congrats! You crushed it. This Hello World C++ tutorial is obviously very basic and only uses a small set of features. As you learn the language, you’ll become more comfortable with the different variables and syntax.

You deserve an A+

You can now officially call yourself a C++ programmer. You’ll be up and running, creating the next Amazon in no time.

Extra credit time! See how C++ is commonly matched with servers, databases, and frameworks to create what’s called a tech stack.

Never miss a post.

Subscribe to keep your fingers on the tech pulse.

By submitting this form, you are agreeing to receive marketing communications from G2.