noknow.dev
Sign inSign up
Course overview
C++ Fundamentals
0 / 39 lessons0%

Getting Started

  • Hello, World!
  • Variables and Data Types
  • Arithmetic and Operators
  • Working with std::string
  • Type Conversion and Casting

Control Flow

  • if / else if / else
  • switch / case
  • while and do-while Loops
  • for Loops
  • break, continue, and Finding Primes

Functions

  • Writing Functions
  • Pass by Value vs. Pass by Reference
  • Overloading and Default Parameters
  • Recursion

Arrays and Strings

  • C-style Arrays
  • std::vector — Dynamic Arrays
  • std::string Deep Dive
  • 2D Arrays and Matrices

Pointers and Memory

  • Memory Addresses and Pointers
  • Dynamic Memory: new and delete
  • References vs Pointers

Object-Oriented Programming

  • Classes and Objects
  • Constructors and Destructors
  • Inheritance
  • Virtual Functions and Polymorphism
  • Operator Overloading

The Standard Template Library

  • std::vector in Depth
  • std::map and std::unordered_map
  • std::set and Sorted Unique Collections
  • STL Algorithms

Templates and Generic Programming

  • Function Templates
  • Class Templates

Modern C++ (C++11/14/17)

  • auto and Range-based for
  • Lambda Functions
  • Smart Pointers
  • Move Semantics

Error Handling and Exceptions

  • try / catch / throw
  • Custom Exception Classes
  • RAII and Resource Management

Overloading and Default Parameters

0m 00s

Multiple Versions of the Same Function

int    area(int side)     { return side * side; }
double area(double r)     { return 3.14159 * r * r; }
int    area(int w, int h) { return w * h; }

cout << area(4);       // 16    (int)
cout << area(2.0);     // 12.56 (double)
cout << area(3, 5);    // 15    (two ints)

Default Parameters

Parameters with defaults are optional at call sites:

string greet(string name, string prefix = "Hello") {
    return prefix + ", " + name + "!";
}
greet("Alice");          // "Hello, Alice!"
greet("Alice", "Hi");   // "Hi, Alice!"

Default parameters must come last in the list.

Your Task

Write repeat(string s, int times = 2) that concatenates s exactly times times.
Example: repeat("ha", 3) → "hahaha"   repeat("ab") → "abab"

Back
cppCtrl+Enter to run
Output

Click "Run" to execute your code.