Copyright 2021 - All rights reserved.
The content contained within this book may not be reproduced, duplicated, or transmitted without direct written permission from the author or the publisher.
Under no circumstances will any blame or legal responsibility be held against the publisher, or author, for any damages, reparation, or monetary loss due to the information contained within this book, either directly or indirectly.
Legal Notice:
This book is copyright protected. It is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part, or the content within this book, without the consent of the author or publisher.
Disclaimer Notice:
Please note the information contained within this document is for educational and entertainment purposes only. All effort has been executed to present accurate, up to date, reliable, complete information. No warranties of any kind are declared or implied. Readers acknowledge that the author is not engaging in the rendering of legal, financial, medical, or professional advice. The content within this book has been derived from various sources. Please consult a licensed professional before attempting any techniques outlined in this book.
By reading this document, the reader agrees that under no circumstances is the author responsible for any losses, direct or indirect, that are incurred as a result of the use of the information contained within this document, including, but not limited to, errors, omissions, or inaccuracies.
Table of Contents
A Comprehensive Beginners Guide
to Learn About the Realms of C++ From A-Z
Simple and Effective Tips and Tricks
to learn C++ Programming Effectively
C++
A Comprehensive Beginners Guide
to Learn About the Realms of
C++ From A-Z
Benjamin Smith
Introduction
C++ is a computer programming language, and as from one perspective, a computer program language is a sequence of instruction fed into a computer that dictate to the computer what to do. These instructions are executed through the flow of electrical impulses that affects the computers memory through interaction with the input and output devices. There are different types of computer programs playing different roles; one program might let a computer perform the role as a financial calculator, while another computer program could transform the computer into a worthy chess opponent.
In the mid-1980s, Bjarne Stroustrup of AT and T Bell Labs developed the C++ programming language. C++ is an extension of the previously developed C programming language by AT and T Labs in the early 1970s. Originally, AT and T developed the C programing language to write UNIX operating systems, system-level software, and embedded system development. Initially, following after the development of the C++ programming language, it provided object-oriented programming features, and later on, generic programming capacities were added.
The C++ programming language is useful in both commercial and industrial software development. C++ is a powerful programming language used for developing complex engineering, sciences, and business systems. Some common software written in C++ include Adobe Creative Suites, macOS, Microsoft Office, Microsoft Windows 8, and so on. The C++ programming language is complex itself so that it can meet up with the needs of commercial software development. Experienced software developers can accomplish great things with C++, but beginners may have a difficult time with it because it is closer to machine language than human language.
Were keen on understanding in this book, and so, to fully understand everything you need to know about C++ programing language, there are some development tools you need to acquit yourself to how they work.
This book is not aimed to cover all facets of the programming language, but to guide you on all, you ought to know about the C++ programming language. Despite the plethora of things you need to know about C++, this book will bring as much of it into ten concise chapters letting you learn all you need to know about C++ from
A-Z.
Chapter 1
Writing a C++ Program
C++ has a particular structure of writing them. The syntax of the code much be correct. If not, the compiler would give an error message, and it would not be executable. In this chapter, we shall be introducing C++ with simple executable examples you can try. Most C++ codes are executable in a lot of other programming languages like C, Ada, C#, and Java but with a slightly different syntax.
The General Structure of a Simple C++ Code
Below is a one of the simplest C++ code that does something:
#include
int main() {
std::cout << General structure of a simple C++ code!\n;
}
The above code is what a simple C++ code looks like. You type it into an editor, and you run it through a compiler, the program will print the message:
General structure of a simple C++ code!
This simple C++ code above is a four non-blank lines of code which includes:
#include
This coding line is a preprocessing directive. The preprocessing directive in the C++ source code always starts with a # symbol. The symbols direct the preprocessor, so it adds a predefined source code to an existing one before compiling the process. This process is automatic. The iostream in this line means we want to use an object from the iostream library. The iostream is a collection of pre-compiled C++ codes executable by the C++ program. The iostream library also contains elements that handle the input and output (I/O) like getting information from the keyboard, dealing with files, and printing a display on the screen.
In the example, std::cout is not a part of the C++ code itself. It is one of those things related to output and input the C++ compiler develop and store in the iostream library. Now the compiler needs to be aware of these iostream items so it can compile the program. So, that is why the #include directive is used to specifies a file called a header, which contains the library code specifications. So, the compiler would use the std::cout to cross-check the specification in the header. A lot of C++ programs make use of the #include directive, although there are other programming codes headers as well.
int main () {
This programming line specifies the actual beginning of the program. In this line, were declaring a function named main. Any C++ program containing this function is executable. The int means integer, which is a fundamental variable a compiler used to assign numeric variables with whole numbers. The opening of the curly brace at the end of the line is the beginning of the main program. Its a rule of thumb that the body of a function must contain the statement of the function to execute.