chapter two

2 Exploring C++ fundamentals

 

This chapter covers

  • Reviewing basic programming concepts
  • Writing your first C++ program
  • Learning about C++ building blocks
  • Understanding principles of memory allocation
  • Declaring and initializing variables
  • Learning about constant variables and when to use them

After reading the first chapter, you are probably excited about diving in and learning C++. In this chapter, we continue the journey as you get familiar with some basic programming concepts, as well as the importance of punctuation, logic, syntactical rules, indentation, and comments in your code. All together they will help you write functioning and beautiful code in C++, which is easy to maintain and follow.

You will start this chapter by learning some basic concepts and definitions in computer programming, and understand the role of the compiler, which turns your code into machine code, and your IDE, which stands for Integrated Development Environment. The IDE is used to write and run your code. We will then move to writing your very first C++ program. We explain every part of code you will write so you can feel comfortable in your first C++ hands-on experience.

2.1 Some basic concepts before we begin

2.1.1 Your Console / Terminal

2.1.2 Shhh… libraries

2.1.3 Header files

2.2 Your first C++ program!

2.2.1 Start writing your code – write a basic and simple code in C++

2.2.2 Step 1: Include the <iostream> header file

2.2.3 Step 2 – Know the main() function – your programs’ entry point

2.3 Know your power tools – the role of the compiler and IDE

2.3.1 The important role of your compiler

2.3.2 The role of your IDE

2.4 The C++ building blocks

2.4.1 C++ reserved keywords

2.4.2 Punctuation – the glue holding it all together

2.4.3 Indentation – appearance is everything

2.4.4 Comments comments comments, (and more comments)

2.4.5 The connection between C++ Syntax and logic

2.4.6 Syntactic sugar and C++ 20

2.5 The basic principles of memory allocation

2.6 Variables – mitigating our human faulty memory with the super-machine

2.6.1 Variables types and size value