Introduction to C++Learn C++

Easily Learn Powerful C++ Programming Language Structure

In general most of codes in programming are text lines, that means you can read codes my any editors i.e. with Notepad, Word, etc. on Windows. C and C++ Compilers, compiles (we can say converts) these lines to machine codes that directly runs in that operating system and links as a executable (*.exe) file. A Compiler (C or C++ Compiler, etc.) is a computer program that converts one programming language (i.e. C/C++ codes) written with text into executable machine code with a linker. Such code may not be as fast as assembler code, but the difference in speed is very small because both machine code and compiler-based code in text form are much more compatible with other CPU/GPUs and/or with other Operating Systems when you compile them on a machine. This is one reason why C++ is the fastest and most powerful programming language. Interpreted programming languages run inside executable applications like Java, Python or Visual Basic. This is why they are slower when executing operations, as they need to use compiled libraries for faster operations. Again, they mostly they use C/C++ compilers to build these libraries. Using an interpreted programming language is like being carried by a runner, while a compiled (non-interpreted) programming language is like running itself. This subtle difference turns into a huge gap when you run the same routine (i.e. for face recognition) millions of times a millisecond.

In this post, we want to show you Structure of C++ Programming Language, it is very important for beginners to understand how code lines work in C++. Dev-C++ is a notable IDE for programming C++ applications on Windows. In C+ Programming Language, structure of simple applications are like this,

Structure of a Simple C or C++ Programming Language;

Basically C++ has two part includes and other definitions outside of main() function and main() function.

In professional coding, applications needs many functions. For example one function may save configuration of your game application and another function may load that configuration. There are many functions that means you need to include many library headers, you also need your Custom Header Files. You also need sub functions may be sub functions of these function, you can also call some functions recursively. So all these should be outside of the main() function.

Structure of an Advanced C++ Programming Language is,

Commands in Libraries are included with #include <…> command and these libraries contain commands, variables, classes. We can say they are like sub programs that has basic commands used in C++. So it is good to know if your command needs a library or it is also same library. For example cout command used to print out texts and variables to screen or to an output like file, printer etc. This command is defined in iostream library, so you must add this library header as given here,

Generally C headers has *.h extension and C++ headers has *.hpp extension. Some standard libraries has no extension. In this line <….> these brackets means it is in default include path of C++ compiler that you are using. Most of include files can be found in C:\Program Files (x86)\Embarcadero\Dev-Cpp\TDM-GCC-64\x86_64-w64-mingw32\include folder.

Main functions are defined as main() here, note that a function in C++, has parentheses and it’s parameters are used in this parentheses. Code lines of these functions are defined in { and } brackets, so a simple main function should be as shown below here,

Here // is used to commenting in lines, that means all text after this is not a C++ code, just a text in code as a reminder. You can use this to note or to remember code lines. As a standard, In Dev-C++ and in most of other C++ compilers main() function has two arguments and it returns an integer number, as given here below,


Dev-C++ Hello World C++ Example

If you are a beginner “Hello World” examples are good to understand feature of that programming language. It is good to understand how to edit text, how to write in its format, how to compile and link, how to debug and execute, how to deploy or release. Hello World example print outs “Hello World” sentence to the screen. Here below is the most common “Hello World” C++ example, the best way to learn a programming language is writing programs. Typically, the first program beginners write is a program called “Hello World”, which simply prints “Hello World” to your computer screen

These examples are also good to understand Structure of C++ Programming Language. Here we have iostream library library and we used cout function to write “Hello World” . If you write this same code, compile and run with F11 in Dev-C++ ( or in many other C++ compilers) this code will print out “Hello Dev-C++ World” to the screen.

Dev-C++ Hello World C Example
If you would like to code same in C format with Dev-C++ you must chose Console – C Language, And code should be like this,

C++ includes all C features and it has many great features and modern ways. In C format, here we have two standard libraries and we used printf() function to write “Hello World”, and this will print out,

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++11C++14C++17C++20Learn C++

What Is The Queue (std::queue) In Modern C++?

C++C++11C++14C++17Learn C++SyntaxTemplates

What Are The Logical Operation Metafunctions In Modern C++?

C++C++14C++17C++20Learn C++

What Are The Deprecated C++14 Features In C++17?

C++C++14C++17C++20Learn C++

What Are The C++14 Features Removed From C++17?