Programming Abstraction in C++ # 01. Overview of C++
1.Overview of C++
1.2 The history of C++
📌Days before C++
People are using machine language which reflects the design of the hardware rather than the needs of programmers.
📌High-level programming language
The first high-level programming language is called FORTRAN(formula translation) which resembles the mathematical formulas into machine language.
📌Object-oriented paradigm
Before it, it is procedural paradigm represented by C. C++ is built of C and shifts the paradigm.
1.3. The compilation process
You should be aware of the following concepts:
- source file
- compiler
- object file
- executable file
- libraries
- linker
1.4. The structure of a C++ program
1.6. Data Types
📌Integer types
If long int
+ int
, the result is int
which will promote the precision.
📌Floating-point types
Floating-point with scientific notation.
xxxxxxxxxx
double num = 2.9979E+8;
E+8
means
📌Characters
ASCII stands for American Standard Code for Information Interchange.
The row stands for 10, col stands for 1. Therefore A
is 65 = 10 * 6 + 5 * 1
📌Strings
The string
is not a primitive type in C++ while it is, in fact, a library type(history artifact with C). In this book, we uses the string
library wherever possible.
1.7. Expressions
📌Mixing types in an expression
The type-conversion is with the following order:
For example:
xxxxxxxxxx
double num = 0;
num += 1;
// num now is 1.0
📌Truncation
It is the operation of discarding a decimal fraction.
xxxxxxxxxx
int result = 9 / 4; //result is 2
📌Type casts
type cast in C++:
xxxxxxxxxx
quotient = double(num) / den;
type cast in C#:
xxxxxxxxxx
quotient = (double) num / den;
📌Embedded Assignment
xxxxxxxxxx
int x, y, z;
z = (x = 6) + (y = 7);
While we don't recommend these kinds of operation which are difficult to understand.
📌Multiple Assignment
xxxxxxxxxx
int n1, n2, n3;
n1 = n2 = n3 = 0;
📌Increment and Decrement Operator
The difference between ++x
and x++
.
xxxxxxxxxx
{
cout << *first << endl;
*at = *first;
at++;
first++;
}
is equivalent to the following:
xxxxxxxxxx
{
cout << *first << endl;
*at++ = *first++;
}
1.8. Statements
📌Predicate Functions
Functions like isVowel()
or isAlphabet
are called predicate functions.