Within Coding User, our team of industry experts and professional coders cover all the tools you need to get coding. From those first few lines of code that will change your world forever to insider tips and tricks to advance your skills and programming abilities. Each issue features up-to-date user tutorials, put together in an easy to follow step-by-step manner, building to create a multi-volumed series that will see you get to grips with code but also improve your knowledge, job prospects, and expand your horizons. Let’s get coding, where the only limit is your own imagination. Subscribe today! 100% Independent! Please note: ALL free content and gifts are also available via this digital edition.
Say Hello to C++
Why C++? • C++ is one of the most popular programming languages available today. Originally called C with Classes, the language was renamed C++ in 1983. It’s an extension of the original C language and is a general purpose object-oriented (OOP) environment.
Equipment Needed • You don’t need to invest a huge amount of money in order to learn C++ and you don’t need an entire computing lab at your disposal either. Providing you have a fairly modern computer, everything else is freely available.
How to Set Up C++ in Windows • Windows users have a wealth of choice when it comes to programming in C++. There are plenty of IDEs and compilers available, including Visual Studio from Microsoft. However, in our opinion, the best C++ IDE to begin with is Code::Blocks.
How to Set Up C++ on a Mac • To begin C++ coding on a Mac you first need to install Apple’s Xcode. This is a free, full featured IDE that’s designed to create native Apple apps. However, you can also use it to create C++ code relatively easily.
How to Set Up C++ in Linux • Linux is a great C++ coding environment. Most Linux distros already have the essential components preinstalled, such as a compiler and the text editors are excellent for entering code into, including colour coding; and there’s tons of extra software available to help you out.
Other C++ IDEs to Install • If you want to try a different approach to working with your C++ code, then there are plenty of options available to you. Windows is the most prolific platform for C++ IDEs but there are plenty for Mac and Linux users too.
Your First C++ Program • You may have followed the Mac and Linux examples previously but you’re going to be working exclusively in Windows and Code::Blocks from here on. Let’s begin by writing your first C++ program and taking the first small step into a larger coding world.
Structure of a C++ Program • C++ has a very defined structure and way of doing things. Miss something out, even as small as a semicolon, and your entire program will fail to be compiled and executed. Many a professional programmer has fallen foul of sloppy structure.
Compile and Execute • You’ve created your first C++ program and you now understand the basics behind the structure of one. Let’s actually get things moving and compile and execute, or run if you prefer, the program and see how it looks.
Using Comments • While comments may seem like a minor element to the many lines of code that combine to make a game, application or even an entire operating system, in actual fact they’re probably one of the most important factors.
Variables • Variables differ slightly when using C++ as opposed to Python. In Python, you can simply state that ‘a’ equals 10 and a variable is assigned. However, in C++ a variable has to be declared with its type before it can be used.
Data Types • Variables, as we’ve seen, store information that the programmer can then later call up, and manipulate if required. Variables are simply reserved memory locations that store the values the programmer assigns,...