Search

The C++ Tutorial (Test Site)

Welcome to the LearnCpp.com test site! It’s Tuesday 19th of October 2021 11:31:52 AM UTC.

You probably shouldn’t be here — this is where we test updates before pushing them to the main site. Please check out http://www.learncpp.com.

LearnCpp.com is a free website devoted to teaching you how to program in C++. Whether you’ve had any prior programming experience or not, the tutorials on this site will walk you through all the steps to write, compile, and debug your C++ programs, all with plenty of examples.

Becoming an expert won’t happen overnight, but with a little patience, you’ll get there. And LearnCpp.com will show you the way.


Chapter 0Introduction / Getting Started
Updated
Introduction to these tutorials
0.2
Revised
Introduction to programming languages
0.3
New
Introduction to C/C++
0.4
Moved
Introduction to C++ development
0.4a
Split
An introduction to the compiler, linker, and libraries
0.5Installing an Integrated Development Environment (IDE)
0.6Creating a console project and compiling your first program
A few common C++ problems
Configuring your compiler: Build configurations
Configuring your compiler: Compiler extensions
Configuring your compiler: Warning and error levels
Chapter 1C++ Basics
1.1Statements and the structure of a program
1.2Comments
1.3Introduction to variables
1.4Variable assignment and initialization
1.5Introduction to iostream: cout, cin, and endl
1.6Uninitialized variables and undefined behaviors
1.7Keywords and naming identifiers
1.8Introduction to literals and operators
1.9Introduction to expressions
1.10Developing your first program
1.xChapter 1 summary and quiz
Chapter 2C++ Basics: Functions and Files
2.1Introduction to functions
2.2Function return values
2.3Introduction to function parameters and arguments
2.4Introduction to local scope
2.5Why functions are useful, and how to use them effectively
2.6Whitespace and basic formatting
2.7Forward declarations and definitions
2.8Programs with multiple code files
2.9Naming collisions and an introduction to namespaces
2.10Introduction to the preprocessor
2.11Header files
2.12Header guards
2.13How to design your first programs
2.xChapter 2 summary and quiz
Chapter 3C++ Basics: Debugging
3.1Types of errors
3.2The debugging process
3.3A strategy for debugging
3.4Basic debugging tactics
3.5More debugging tactics
3.6Using an integrated debugger: Stepping
3.7Using an integrated debugger: Running and breakpoints
3.8Using an integrated debugger: Watching variables
3.9Using an integrated debugger: The call stack
3.10Finding issues before they become problems
3.xChapter 3 summary and quiz
Chapter 4Fundamental Data Types
4.1Introduction to fundamental data types
4.2Void
4.3Object sizes and the sizeof operator
4.4Signed integers
4.5Unsigned integers, and why to avoid them
4.6Fixed-width integers and size_t
4.7Introduction to scientific notation
4.8Floating point numbers
4.9Boolean values
4.10Introduction to if statements
4.11Compound statements and nested blocks
4.11Chars
4.12An introduction to std::string
4.13Literals
4.14Const, constexpr, and symbolic constants
4.xChapter 4 summary and quiz
Chapter 5Operators
5.1Operator precedence and associativity
5.2Arithmetic operators
5.3Modulus and Exponentiation
5.4Increment/decrement operators, and side effects
5.5Comma and conditional operators
5.6Relational operators and floating point comparisons
5.7Logical operators
5.xChapter 5 comprehensive quiz
Chapter OMiscellaneous
O.1Bit flags and bit manipulation via std::bitset
O.2Bitwise operators
O.3Bit manipulation with bitwise operators and bit masks
O.4Converting between binary and decimal
Chapter 6Object Scope
6.1Compound statements (blocks)
6.2User-defined namespaces and the scope resolution operator
6.3Local variables
6.4Introduction to global variables
6.5Variable shadowing (name hiding)
6.6Internal linkage
6.7External linkage
6.9Why (non-const) global variables are evil
6.8Using global constants in multiple files, and inline variables
6.10Static local variables
6.11Scope, duration, and linkage summary
6.12Using declarations and using directives
6.13Unnamed and inline namespaces
6.xChapter 6 summary and quiz
Chapter ALocal and global variables (new)
Chapter 7Control Flow and Error Handling
7.1Control flow introduction
7.2If statements and blocks
7.3Common if statement problems
7.4Switch statement basics
7.5Switch fallthrough and scoping
7.6Goto statements
7.7Intro to loops and while statements
7.8Do while statements
7.9For statements
7.10Break and continue
7.11Halts (exiting your program early)
7.12Introduction to testing your code
7.13Code coverage
7.14Common semantic errors in C++
7.15Detecting and handling errors
7.16std::cin and handling invalid input
7.17assert and static_assert
7.xChapter 7 summary and quiz
Chapter 8Type conversions and function overloading (new)
8.1Implicit type conversion (coercion)
8.2Floating-point and integral promotion
8.3Numeric conversions
8.4Arithmetic conversions
8.5Explicit type conversion (casting)
8.6Typedefs and type aliases
8.7Type deduction for objects using the auto keyword
8.8Type deduction for functions
8.9Introduction to function overloading
8.10Function overload differentiation
8.11Overloaded function resolution
8.12Default arguments
8.13Function templates
8.14Function template instantiation
8.15Function templates with multiple template types
8.x+-+Chapter+8+summary+and+quiz
Chapter 9Compound Types (draft)
8.1Introduction to compound data types
8.2Value categories (r-values and l-values)
8.3L-value references
8.4L-value references to const
8.5Pass by reference
8.6Pointers
8.7Null pointers
8.8Pointers and const
8.9Pass by address
8.10Return by reference and return by address
8.11Introduction to program-defined types
8.2Introduction to unscoped enumerations
8.3Unscoped enumeration input and output
8.3Scoped enumerations (enum classes)
8.12Struct definition and member selection
8.13Struct initialization
8.14Struct passing and miscellany
Chapter 10Arrays, Strings, and Vectors (draft)
7.11Introduction to class types
5.9Random number generation
7.xChapter 7 summary and quiz
Chapter 11Dynamic memory allocation
10.2In and out parameters



Chapter 6 Arrays, Strings, Pointers, and References (old)
6.1
Updated Jul 22
Arrays (Part I)
6.2
Updated Jul 27
Arrays (Part II)
6.3
Updated Jul 27
Arrays and loops
6.3a
New Jul 31
For each loops
6.4
Updated Aug 3
Sorting an array using selection sort
6.5
Updated Aug 5
Multidimensional arrays
6.6
Updated Aug 9
C-style strings
6.6a
New Oct 29
An introduction to std::string_view
6.7
Updated Aug 12
Introduction to pointers
6.7a
New Aug 12
Null pointers
6.8
Updated Aug 24
Pointers and arrays
6.8a
New Aug 15
Pointer arithmetic and array indexing
6.8b
New Aug 15
C-style string symbolic constants
6.9
Updated Aug 18
Dynamic memory allocation with new and delete
6.9a
New Aug 18
Dynamically allocating arrays
6.10
Updated Aug 20
Pointers and const
6.11
Updated Sep 7
Reference variables
6.12
Updated Aug 21
Member selection with pointers and references
6.13
Updated Aug 25
Void pointers
6.14
New Sep 14
Pointers to pointers
6.15
New Sep 14
An introduction to std::array
6.16 An introduction to std::vector
6.17 Introduction to iterators
 
Chapter 7 Functions
7.1 Function parameters and arguments
7.2 Passing arguments by value
7.3 Passing arguments by reference
7.4 Passing arguments by address
7.4a Returning values by value, reference, and address
7.5 Inline functions
7.6 Function overloading
7.7 Default parameters
7.8 Function pointers
7.9 The stack and the heap
7.10 Recursion
7.11 (“Namespaces” moved to 4.3a)
7.12 Handling errors (assert, cerr, exit, and exceptions)
7.13 Command line arguments
7.14 Ellipses (and why to avoid them)
 
Chapter 8 Basic object-oriented programming
8.1 Welcome to object-oriented programming
8.2 Classes and class members
8.3 Public vs private access specifiers
8.4 Access functions and encapsulation
8.5 Constructors
8.6 Destructors
8.7 The hidden “this” pointer
8.8 Constructors (Part II)
8.9 Class code and header files
8.10 Const class objects and member functions
8.11 Static member variables
8.12 Static member functions
8.13 Friend functions and classes
8.14 Anonymous variables and objects
Chapter 9 Operator overloading
9.1 Introduction to operator overloading
9.2 Overloading the arithmetic operators
9.3 Overloading the I/O operators
9.4 Overloading the comparison operators
9.5 Overloading unary operators +, -, and !
9.6 Overloading operators using member functions
9.7 Overloading the increment and decrement operators
9.8 Overloading the subscript operator
9.9 Overloading the parenthesis operator
9.10 Overloading typecasts
9.11 The copy constructor and overloading the assignment operator
9.12 Shallow vs. deep copying
 
Chapter 10 Composition
10.1 Constructor initialization lists
10.2 Composition
10.3 Aggregation
10.4 Container classes
 
Chapter 11 Inheritance
11.1 Introduction to inheritance
11.2 Basic inheritance in C++
11.3 Order of construction of derived classes
11.4 Constructors and initialization of derived classes
11.5 Inheritance and access specifiers
11.6 Adding, changing, and hiding members in a derived class
11.7 Multiple inheritance
11.8 Virtual base classes
 
Chapter 12 Virtual Functions
12.1 Pointers and references to the base class of derived objects
12.2 Virtual functions and polymorphism
12.3 Virtual destructors, virtual assignment, and overriding virtualization
12.4 Early binding and late binding
12.5 The virtual table
12.6 Pure virtual functions, abstract base classes, and interface classes
 
Chapter 13 Input and output (I/O)
13.1 Input and output (I/O) streams
13.2 Input with istream
13.3 Output with ostream and ios
13.4 Stream classes for strings
13.5 Stream states and input validation
13.6 Basic file I/O
13.7 Random file I/O
 
Chapter 14 Templates
14.1 Function templates
14.2 Function template instances
14.3 Template classes
14.4 Expression parameters and template specialization
14.5 Class template specialization
14.6 Partial template specialization
 
Chapter 15 Exceptions
15.1 The need for exceptions
15.2 Basic exception handling
15.3 Exceptions, functions, and stack unwinding
15.4 Uncaught exceptions, catch-all handlers, and exception specifiers
15.5 Exceptions, classes, and inheritance
15.6 Exception dangers and downsides
14.9
New
Exception specifiers and noexcept
15.4a
New
std::move_if_noexcept
 
Chapter 16 The Standard Template Library
16.1 The Standard Template Library (STL)
16.2 STL containers overview
16.3 STL iterators overview
16.4 STL algorithms overview
 
Chapter 17 std::string
17.1 std::string and std::wstring
17.2 std::string construction and destruction
17.3 std::string length and capacity
17.4 std::string character access and conversion to C-style arrays
17.5 std::string assignment and swapping
17.6 std::string appending
17.7 std::string inserting
 
Appendix A Miscellaneous Subjects
A.1 Static and dynamic libraries
A.2 Using libraries with Visual Studio Express 2005
A.3 Using libraries with Code::Blocks
 
Appendix B C++11 (Formerly C++0x)
B.1 Introduction to C++11
B.2 Long long, auto, decltype, nullptr, and enum classes
B.3 Range-based for statements and static_assert
B.4 Initializer lists and uniform initialization
B.5 Delegating constructors
B.6 New virtual function controls (override, final, default, and delete)