Introduction to C++

Course data




Online references

Week 1

  1. The stories of numbers, computing machines, computer languages
  2. The scheme of a digital computer: CPU, memory, I/O devices, peripherials, operation systems
  3. Algorithms, algorithmization, functions as bookbinderies
  4. Functions (=bookbindery, Corvinas), their arguments, parameters and side effects
  5. Text editors (Notepad++, Vim, Emacs, jedit, gedit), file system tree, terminals, executables
  6. C++ installation on Windows MinGW, Linux GNU and virtual machines
  7. Integrated development environments (IDE), Code::Blocks
  8. Compiling, linking, executing, compiler errors, warnings

Week 2

Errors and warnings

unterminated comment
You left out a semicolon at the end of a statement.

parse error before <something>
Probably a missing semicolon or brace before an element, though it could be something else.

syntax error before <something>
You tried to use an operator or keyword that doesn't belong there. Alternatively, you might have mispelled something (remember that C++ is case sensitive).

missing terminating " character
You left out the terminating double-quotes of a string literal.

cout undeclared (first use this function)
You forgot to put #include <iostream> at the top of your source file.

warning: multi-line string literals are deprecated
You did something like this:

Variable types

GroupType namesNotes on size / precision
Character typescharExactly one byte in size. At least 8 bits.
 char16_tNot smaller than char. At least 16 bits.
 char32_tNot smaller than char16_t. At least 32 bits.
 wchar_tCan represent the largest supported character set.
Integer types (signed)signed charSame size as char. At least 8 bits.
 signed short intNot smaller than char. At least 16 bits.
 signed intNot smaller than short. At least 16 bits.
 signed long intNot smaller than int. At least 32 bits.
 signed long long intNot smaller than long. At least 64 bits.
Integer types (unsigned)unsigned char(same size as their signed counterparts)
 unsigned short int 
 unsigned int 
 unsigned long int 
 unsigned long long int 
Floating-point typesfloat 
 doublePrecision not less than float
 long doublePrecision not less than double
Boolean typebool 
Void typevoidno storage
Null pointerdecltype(nullptr) 

Week 3

Preprocessor directives






Convert Fahrenheit to Celsius: BAD VERSION!


Week 4

Operator precedence

1::Scope resolutionLeft-to-right
2a++ a--Suffix/postfix increment and decrement 
 type() type{}Functional cast 
 a()Function call 
 . ->Member access 
3++a --aPrefix increment and decrementRight-to-left
 +a -aUnary plus and minus 
 ! ~Logical NOT and bitwise NOT 
 (type)C-style cast 
 *aIndirection (dereference) 
 sizeofSize-of[note 1] 
 new new[]Dynamic memory allocation 
 delete delete[]Dynamic memory deallocation 
4.* ->*Pointer-to-memberLeft-to-righ
5a*b a/b a%bMultiplication, division, and remainder 
6a+b a-bAddition and subtraction 
7<< >>Bitwise left shift and right shift 
8<=>Three-way comparison operator (since C++20) 
9< <=For relational operators < and ≤ respectively 
 > >=For relational operators > and ≥ respectively 
10== !=For relational operators = and ≠ respectively 
11&Bitwise AND 
12^Bitwise XOR (exclusive or) 
13|Bitwise OR (inclusive or) 
14&&Logical AND 
15||Logical OR 
16a?b:cTernary conditional[note 2]Right-to-left
 throwthrow operator 
 =Direct assignment (provided by default for C++ classes) 
 += -=Compound assignment by sum and difference 
 *= /= %=Compound assignment by product, quotient, and remainder 
 <<= >>=Compound assignment by bitwise left shift and right shift 
 &= ^==Compound assignment by bitwise AND, XOR, and OR



Week 5



Week 6

Declaration, definition

Life, lifetime

Pointers, arrays, structures

Week 7

Command line arguments


Week 8

Examples of objects, classes, templates

Character arrays vs. string objects (public member functions)

Operator nameDescription
operator+=Append to string
appendAppend to string
assignAssign content to string
insertInsert into string
eraseErase characters from string
replaceReplace portion of string
c_strGet C string equivalent
dataGet string data
copyCopy sequence of characters from string
findFind content in string
substrGenerate substring
compareCompare strings

Container class templates

Examples: <>

array, vector, list

deque, queue, stack


Week 9

Week 10 and 11

Week 12 and 13

Week 14