May 25, 2018
Starting with C++ Programming
Hi, you opened this tutorial because you want to learn C++. This page will get you started and help you to write you first C++ program!
Firstly you need to get a C++ compiler, there are tons on Google. I will use Dev C++ as my compiler and CodeBlocks as my IDE. This is your program’s source.
using namespace std;
Now that looks confusing. Well its not! Now the first line means you are calling a library to use, iostream is part of the standard library. It is really refered to as InputOutputStream. In other words it allows to to get input and throw an output.
Next is line 3. Each of the standard libraries has a namespace abreviated as std. We are telling C++ that we are using the standard namespace. Each program needs a main statement. It indicates that that is where the program starts. So we write int main. The int says we are going to return a value if needed.
Line 6 indicates that we are starting our program, while line 9 says that we are ending it. Line 7 says that we are going to write a message “Hello world!” and go to the next line. An easy way to remember this is cout stands for character out, in other words, words out.
The Thats it! You wrote your first C++ program! This is a quick tutorial and doesn’t teach, classes, templates, friends, variables etc, but if I get enough hits, I will gladly write about all of those!