##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Explore individual topics with detailed lessons and practice problems.
You are about to learn C++. I will show you what it is, where it is used, and how to write your first program.
Your programs need to store data. I will show you how variables work, what types exist, and which one to pick for each situation.
You are about to learn C++. I will show you what it is, where it is used, and how to write your first program.
The Goal
Games, systems, browsers
Skills you will build
repovive.com/compiler
Complete working example
Your first program
Program structure
Personalized greeting
Adding external code
Library definitions
Understanding #include
Avoiding std:: prefix
Where execution starts
Program entry point
Reusable code blocks
Displaying text
Moving to next line
Test your understanding
Signaling completion
Ending each instruction
Statement termination
Grouping statements together
Punctuation rules
Explaining code briefly
Longer explanations
Code documentation
Helping future readers
Language structure
Code documentation
Code to machine code
The semicolon rule
Statement termination
Unclosed code blocks
Misspelling reserved words
Interpreting compiler feedback
Identifying mistakes
Making structure visible
Choosing clear identifiers
Valid identifiers
Practice output statements
Creating text art
Simple output problem
Main approach
Complete solution
What we learned
Interactive program basics
Main approach
Complete solution
What we learned
What we learned
Your programs need to store data. I will show you how variables work, what types exist, and which one to pick for each situation.
The Goal
Containers for values
What types exist
Storing integers
What fits in int
Integer types
Going past limits
Test your understanding
64-bit integers
Avoiding overflow bugs
Large integers
Marking large constants
Floating-point values
Not infinite precision
Integer type
When rounding matters
Decimals vs integers
Decimal numbers
Storing letters
The character encoding
Math with letters
Add two numbers
Test your understanding
Binary states
Using bool with if
Storing words
Working with text
Calculate with doubles
Text storage
How to create them
Legal identifiers
Data storage
Readable code
Starting values
Data storage
Random data
Unchangeable variables
Safer code
Data storage
Silent changes
Forced changes
Data storage
Typical errors
Displaying values
Combining text and data
Integer type
Practice with variables
Practice with doubles
First real problem
Main approach
Working solution
What we learned
Celsius to Fahrenheit
Formula application
Working solution
What we learned
What we learned
Your programs need to get data from users and display results. I will show you how to read different types, handle errors, and format output.
The Goal
The extraction operator
Reading from the input buffer
Integer input
Floating-point input
Input operations
Character input
Test your understanding
Chained extraction
Sequential reads
Reading in correct sequence
Test your understanding
String extraction
Spaces terminate extraction
Reading entire lines
Common mixing error
Apply a formula
Reading full lines
Discarding leftover characters
Why inputs fail
Understanding failure state
Knowledge check
Detecting read errors
Controlling output appearance
Controlling decimal digits
Counter-based loop
Notation styles
Field width control
Conditional execution
Reading unknown quantity
Processing all input
User-controlled termination
Practice reading and computing
Practice string input
First CF problem
Main approach
How to solve
Knowledge check
Complete solution
What we learned
Multiple test cases
Main approach
Handle n test cases
Large integers
How to solve
Complete solution
What we learned
What we learned
I will show you how to perform calculations and make decisions. You will learn arithmetic, comparison, and logical operators.
The Goal
Operators transform values
Basic math operations
Combining and removing values
Scaling values
Math operators
Whole number results only
Full decimal answers
Integer division
What is left over
Practical applications
Test modulo knowledge
Which operator goes first
Override default precedence
Test precedence rules
The equals sign
Use the modulo operator
Shorthand arithmetic
Add or subtract one
Timing of the change
Operator basics
Test your understanding
Compare two values
Testing conditions
Checking sameness
Ordering values
Inclusive bounds
Operator basics
Test comparison rules
Merging multiple checks
All conditions required
Logical AND
Any condition sufficient
Flipping true and false
Logical AND
Early exit optimization
Test logical rules
Apply remainder operator
Multiple logical rules
Count qualifiers
The threshold condition
Breaking down the solution
Operator basics
Complete solution
summary
Finding distinct digits
Using modulo and division
Breaking down the solution
Conditional execution
Complete solution
summary
What we learned
Your programs need to make decisions. Learn if-else, switch, and how to combine conditions logically.
The Goal
Understanding program paths
Running code conditionally
What goes in parentheses
Test understanding
Choosing between alternatives
When to use if-else
Conditional execution
Test understanding
More than two paths
How conditions are checked
Conditional execution
Why sequence matters
Test understanding
Testing within branches
Choosing the right structure
Conditional execution
Which if owns the else
Test understanding
Testing relationships
Requiring multiple conditions
Multiple conditions
Equality check
Alternative conditions
Testing for false
Test understanding
Choosing from constants
Structure of switch
Multi-way branching
Exiting the switch
Intentional case sharing
Loop exit
Handling unexpected values
Test understanding
Discrete value matching
Avoiding errors
Conditional execution
Converting scores to letters
Four operations
Multiple rules with &&
Solving problems together
Sum and compare
Breaking it down
Knowledge check
Complete solution
summary
Reordering addition
Parse then reorder
Breaking it down
Knowledge check
Complete solution
summary
What we learned
Loops let you repeat code without copying. Learn while, for, and do-while to iterate over data.
The Goal
The concept of iteration
Basic while loop structure
How to write while loops
Understanding the test
Test understanding
Using loops to count
Loops that never stop
Variables that control loops
Test understanding
Counting made simple
Structure breakdown
Starting the loop
When to keep going
Repetition basics
Advancing the counter
Basic for loop
Test understanding
Standard forward iteration
Reverse iteration
Post-check loop
Non-unit increments
Loop with accumulator
Test understanding
When to use each
Execute then check
Condition-based loop
How to write do-while loops
Guaranteeing first execution
Condition-based loop
Test understanding
Stopping loops mid-execution
When to exit early
Multiplication loop
Loop exit
Jumping to next iteration
When to use continue
Skip iteration
Test understanding
Multi-level iteration
Common use cases
Avoiding boundary bugs
Adding values in a loop
Finding dangerous patterns
Main approach
Breaking down the solution
Repetition basics
Working solution
Following the execution
What we learned
Checking lucky property
Main approach
Breaking down the solution
Repetition basics
Working solution
Following the execution
What we learned
What we learned
Arrays store multiple values of the same type. Learn to declare, access, and iterate over arrays.
The Goal
Indexed containers
Benefits of using arrays
How to declare an array
Understanding fixed sizing
Test understanding
Reading and writing values
Why arrays start at index 0
Zero-based indexing
Invalid index dangers
Test understanding
Providing initial values
When you provide fewer values
C++11 brace initialization
Test understanding
Visiting each element
Traverse and accumulate
Standard iteration structure
Calculate array length
Test understanding
Updating array contents
Processing all elements
Search through array
Locating the smallest element
Locating the largest element
Collection basics
How many meet a condition
Test understanding
How arrays are passed
Why sizeof fails in functions
Why you need a size parameter
Test understanding
Arrays of arrays
Declaring and initializing
Iterating over all elements
Reversing order of elements
Detecting repeated elements
Counting adjacent same colors
Adjacent comparison pattern
Traversal approach
Collection basics
Working solution
What we learned
Filtering with conditions
Difference calculation
Count-as-you-go approach
Collection basics
Working solution
What we learned
What we learned
Strings handle text in your programs. Learn the C++ string class and common string operations.
The Goal
Understanding string concept
Comparing approaches
Using the string type
Creating string variables
Text storage
Test understanding
Giving strings content
Strings with no content
Text storage
Measuring string size
Test understanding
Getting individual letters
Changing individual letters
Protected character access
Test understanding
Combining text
Combining with plus
Text storage
Adding to existing strings
Test understanding
Testing string relationships
How strings are ordered
Text storage
Letter case in comparisons
Test understanding
Reading single words
Reading full lines
Text storage
Handling leftover newlines
Test understanding
Getting portions of strings
Locating text
Text storage
Handling failed searches
Test understanding
Processing each character
Simpler character access
Text storage
Flip text order
Finding specific characters
Comparing two strings
Convert before comparing
Breaking down the solution
Text storage
Complete solution
summary
Transform and rebuild string
Classify then transform
Breaking down the solution
Text storage
Complete solution
summary
What we learned
Stop repeating yourself. Learn to define reusable blocks of code, pass data in, get results back, and organize your programs into logical pieces.
Why functions matter
The core concept
How to write one
Running the code
Functions that just do work
Function types
How functions give results
Code organization
Input terminology
How data flows in
Function inputs
Write your first function
More than one value
Setting fallback values
Function inputs
Signatures vs implementations
Reusing across files
Boolean return type
Where variables live
Understanding #include
Creation and destruction
Multiple versions
Functions calling themselves
Code organization
Small reusable pieces
Celsius to Fahrenheit
Checking number parity
Test your understanding
Returning the larger value
Multiple parameters
Using void functions
Checking bounds
Recursion or loops
Checking divisibility
Test your understanding
Pass by value limits
Iterative or recursive
Fitting dominoes on a board
Think about total space
Breaking down the solution
Post-check loop
Complete solution
summary
Checking force balance
Add each dimension separately
Breaking down the solution
Code organization
Complete solution
summary
What we learned
Work with memory directly. Learn how pointers store addresses, how references create aliases, and when to use each for efficient parameter passing.
Memory addresses and aliases
Understanding memory locations
Using & to find addresses
Variables that store addresses
Pointer syntax
Creating pointer variables
Using * to get values
Predict the output
Using nullptr
Array names as addresses
Adding to pointers
Understanding movement
Aliases for variables
Variable aliases
Variable alias
Key differences
Understanding aliases
Function parameter technique
Avoiding copies safely
Variable alias
Choosing the right tool
Function parameter behavior
Avoid common crashes
Safe pointer habits
Writing swap function
Verify your approach
Using pointer arithmetic
Combining techniques
Avoiding errors
Dereferencing practice
Multiple names scenario
Predicting results
Preventing crashes
Using two pointers
Understanding the algorithm
Computing several values
Using const references
Understanding restrictions
Tracking gift exchanges
Inverting the mapping
Breaking down the solution
Complete solution
Following the execution
summary
Integer type
Finding position in grid
Counting steps in grid
Breaking down the solution
Conditional execution
Complete solution
summary
What we learned
Group related data into custom types. Learn to define structs, access members, pass them to functions, and build organized data structures.
Why structs matter
Grouping related data
How to create one
Making actual objects
Getting to the data
Struct access
Updating struct values
Different init methods
Custom data types
What happens without init
Arrays inside structs
Storing many structs
Custom data types
Multiple levels deep
Functions with struct params
How structs are passed
Custom data types
Efficiency with references
Safe and efficient
Variable alias
Functions that give structs
Composition patterns
Chaining member access
Test your understanding
What's the difference
Distance between points
Track student information
Calculate from corners
Test your understanding
Typical errors
Making the choice
Equilibrium with structs
Group related coordinates
Breaking down the solution
Custom data types
Complete solution
summary
Counting uniform conflicts
Bundle related attributes
Breaking down the solution
Custom data types
Complete solution
summary
What we learned
Work with dynamic arrays that grow and shrink. Learn vectors, the most used container in C++, and start exploring the Standard Template Library.
Why vectors matter
Understanding vector basics
Getting started
Declaration syntax
Vector creation
Starting with values
Reading vector values
Dynamic arrays
How vectors manage space
Growing your vector
Shrinking your vector
Dynamic arrays
Precise modifications
Starting fresh
Processing each element
Dynamic arrays
Cleaner iteration
Function parameters
Avoiding copies
Dynamic arrays
Creating grids
Handy shortcuts
Dynamic arrays
Using the sort function
Practice with vectors
Practice with vectors
Practice with vectors
Test your understanding
Practice with vectors
Practice with vectors
Practice with vectors
Comparing containers
Typical errors
Dynamic arrays
Optimization basics
Planning a route
Circular arithmetic
Breaking it down
Dynamic arrays
Complete solution
summary
Choosing opponents
Weakest first
Breaking it down
Dynamic arrays
Complete solution
summary
What we learned
Store key-value pairs and unique collections. Learn maps and sets for lookups and deduplication.
Section Overview
Basic concept
How to declare
How to add entries
Knowledge check
How to get values
Does key exist?
Key-value storage
Processing all entries
Test your understanding
Deleting map entries
Two map types
Key-value storage
Knowledge check
Collection basics
How to declare
Unique elements
How to add
Is element present?
Unique elements
Knowledge check
Processing elements
How to delete
Unique elements
Two set types
Non-unique sets
Unique elements
Non-unique maps
Finding ranges
Key-value storage
Knowledge check
Counting occurrences
Unique elements only
Key-value storage
Classic problem
Character tracking
Grouping pattern
Knowledge check
Custom sorting
Using sets for uniqueness
Automatic deduplication
Breaking it down
Key-value storage
Complete solution
summary
Using maps for counting
Counting occurrences
Breaking it down
Key-value storage
Complete solution
summary
What we learned
Group multiple values without custom structs. Learn pairs for coordinates and tuples for returns.
Section Overview
Basic concept
Construction methods
Reading values
Knowledge check
How operators work
Storing multiple pairs
Two-value container
Automatic ordering
Knowledge check
Key-value pairs
Beyond two elements
Two-value container
Construction syntax
Knowledge check
Compile-time indexing
Automatic extraction
Ordering rules
Knowledge check
Assign to existing variables
Choosing the right tool
Two-value container
Common pattern
Knowledge check
Geometric applications
Representing connections
Storing priorities
Knowledge check
Clean map traversal
When to stop
Two-value container
Avoiding copies
Knowledge check
Modifying pairs
Common mistakes
Two-value container
Exercise
Exercise
Key-value storage
Exercise
Rearranging soldiers
Paired information
Breaking it down
Two-value container
Complete solution
summary
Room availability
Simple filtering
Breaking it down
Two-value container
Complete solution
summary
What we learned
Replace common loops with pre-built algorithms. Learn sort, find, binary_search, and iterators.
Why algorithms matter
Required includes
Default sorting
Changing sort order
Algorithm header
Reversing ranges
Locating min and max
Knowledge check
Searching for values
Count occurrences
Find insertion point
Knowledge check
Finding insertion points
Beyond the value
Practical usage
Knowledge check
Computing totals
Initializing ranges
Consecutive duplicates only
Knowledge check
Complete deduplication
All arrangements
Trying all orders
Knowledge check
Chaining operations
Frequency analysis
Ordering elements
Processing elements
Knowledge check
What to avoid
Proper usage
Choosing wisely
Hands-on coding
Counter-based loop
Knowledge check
Search challenges
Arrangement challenges
Reordering expression
Character filtering
Breaking it down
Knowledge check
Complete solution
summary
Finding positions
Counting moves
Breaking it down
Knowledge check
Complete solution
summary
What we learned
Learn object-oriented programming. Create classes with member variables, methods, and constructors.
The Goal
User-defined types
Concrete entities
Basic structure
Declaring instances
Default access
Controlling visibility
Hiding internals
Conditional execution
Object state
Object behavior
Member access
Using objects
Knowledge check
Self-reference
Controlled access
Initialization function
No parameters
Custom data types
Custom initialization
Multiple constructors
Efficient initialization
Knowledge check
Cleanup function
Implementation details
Acquisition is initialization
Automatic invocation
Custom data types
Knowledge check
Copying objects
Shallow vs deep copy
Default access
Knowledge check
Class-level data
Read-only methods
Member access
Knowledge check
Build complete class
RAII practice
Default access
Knowledge check
Force equilibrium check
Encapsulating vector data
Breaking it down
Default access
Complete solution
summary
Color matching check
Pairing and checking
Breaking it down
Default access
Complete solution
summary
What we learned
Build class hierarchies. Use inheritance, virtual functions, and polymorphism for flexible code.
Building class hierarchies
Sharing class behavior
Parent and child relationship
Declaring derived classes
Members passed to derived
Class extension
Knowledge check
Inheritance visibility
Access from derived classes
Class extension
Initializing base parts
Cleanup from derived to base
Class extension
Replacing base behavior
Knowledge check
Name resolution in inheritance
Runtime type selection
Class extension
Enabling polymorphic calls
Syntax and rules
Polymorphism
Runtime dispatch mechanism
Knowledge check
Forcing derived implementation
Non-instantiable base classes
Code organization
Can it be instantiated?
Pure abstract classes
Preventing memory leaks
Knowledge check
Explicit override declaration
Preventing further overrides
Class extension
Inheriting from multiple bases
Shared base duplication
Knowledge check
Design decision guidelines
Build polymorphic system
Class extension
Abstract class design
Knowledge check
Fix memory leak
Experiment with keywords
OOP force calculation
Inheritance benefits
Implementation approach
Counter-based loop
Pseudocode solution
summary
Virtual methods
Polymorphism benefits
Implementation approach
Conditional execution
Pseudocode solution
summary
What we learned
Read from and write to files. Use ifstream and ofstream to handle file data in your programs.
Reading and writing files
File stream library
Reading from files
Writing to files
Accessing existing files
Counter-based loop
Creating and overwriting files
Validating stream state
Conditional execution
Knowledge check
Extracting formatted data
Handling full lines
Processing individual tokens
Byte-level file access
Character type
Formatted output to files
Structured text output
Resource cleanup
Knowledge check
Controlling open behavior
Preserving existing content
Understanding file formats
Raw byte input
Knowledge check
Raw byte output
Knowledge check
Random access navigation
Querying current position
Detecting file boundaries
Standard code templates
Knowledge check
Detecting and recovering
Knowledge check
Automatic resource management
Read and write exercise
File analysis exercise
Knowledge check
File input basics
File reading pattern
Implementation approach
Pseudocode solution
summary
File output basics
File writing pattern
Implementation approach
Knowledge check
Pseudocode solution
summary
What we learned
Handle errors gracefully with try, catch, and throw. Use exceptions for error recovery.
Error handling with exceptions
Separating errors from logic
Error codes get ignored
Marking risky operations
Triggering exception handling
Exception handling
Responding to exceptions
First exception handler
Exception handling
Knowledge check
Avoiding object slicing
Handling different error types
Variable alias
Unknown exception types
Built-in error types
Error signaling
Top of exception hierarchy
Two main exception categories
Error signaling
Knowledge check
Specific error types
Domain-specific error types
Error signaling
Proper exception derivation
Getting error descriptions
Error signaling
Passing errors upward
How exceptions travel upward
Error signaling
Knowledge check
Functions that never throw
Choosing error mechanisms
Error signaling
Comparing error strategies
Knowledge check
Guarantees about error states
Automatic resource cleanup
Error signaling
Knowledge check
Apply exception handling
Exception handling review
Error handling fundamentals
Exception benefits
Implementation approach
Integer division
Pseudocode solution
summary
Catching different errors
Catching by type
Implementation approach
Error signaling
Pseudocode solution
summary
What we learned
Allocate memory at runtime with new and delete. Understand stack vs heap and avoid memory leaks.
Memory control
Memory layout
Local variables
Long-lived data
Heap allocation
Memory allocation
Manual cleanup
Heap array allocation
Memory cleanup
Knowledge check
Forgetting delete
Deleted memory access
Repeated free
Defensive programming
Allocation decisions
Memory cleanup
Variable-sized allocation
Grow and shrink
Knowledge check
Manual management risks
Automatic cleanup
Single owner
Factory function
Scope-based delete
Knowledge check
Ownership transfer
Knowledge check
Multiple owners
Factory function
Ownership tracking
Last owner cleanup
Variable alias
Non-owning reference
Knowledge check
Ownership patterns
Modern C++ practice
Apply what you learned
Knowledge check
Heap memory basics
Memory location matters
Implementation approach
Pseudocode solution
summary
Heap-based data structures
Building chains
Implementation approach
Knowledge check
Pseudocode solution
summary
What we learned