2 Exploring C++ fundamentals

 

This chapter covers

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

In this chapter, you'll learn the fundamental programming concepts, including the role of punctuation, logic, syntax, indentation, and comments in writing functional and aesthetically pleasing code in C++. We'll cover the basics of computer programming and the compiler's function, which transforms your code into machine language, and the IDE (Integrated Development Environment). Additionally, we'll assist you in writing your first C++ program and interpreting every part of your code, allowing you to feel at ease with your first C++ hands-on experience.

2.1 Some basic concepts before we begin

2.1.1 Your operating system - The wizard behind the curtain

2.1.2 Your Console / Terminal – because who needs the mouse?

2.1.3 Shhh… libraries

2.1.4 Header files – no need to reinvent the wheel

2.1.5 Namespace – avoid name conflicts

2.1.6 A word about Keywords

2.1.7 The important role of your compiler

2.1.8 Your IDE - your power tool

2.2 Ready, set, code: your first C++ program

2.2.1 Start writing your code – write 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 Respect your code (it will respect you back)

2.3.1 Indentation – appearance is everything

2.3.2 Comments comments comments, (and more comments)

2.3.3 Dr. Brain and Mr. Google – why you don’t need to over-memorize things

2.3.4 How the C++ Syntax and your program’s logic are tied

2.3.5 Sweeet! Syntactic sugar and C++ 20

2.4 Memory is king: Variables and memory

2.5 Variables – the backbone of your code

2.5.1 Like a lid to a pot - every variable has a data type

2.5.2 Rolling up our sleeves: how to actually work with variables

2.5.3 Naming names: best practices in naming your variables

2.5.4 With added value - Initializing variables

2.5.5 Code practice – let’s test what you learned so far

2.5.6 Constant variables – make an unbroken promise

2.5.7 Local and global variables – variables in or out of main()

2.6 Final code practice

2.7 Summary