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

Memory Addresses and Pointers

0m 00s

Understanding Memory

Every variable lives at an address in memory. A pointer stores that address:

int x = 42;
int* p = &x;    // p holds the address of x
                 // & means "address of"

cout << x;       // 42   (the value)
cout << &x;      // 0x... (the address)
cout << p;       // same address
cout << *p;      // 42   (* means "dereference: read value at that address")

Modifying through a pointer

int n = 10;
int* ptr = &n;
*ptr = 99;        // changes n!
cout << n;        // 99

null pointer

int* p = nullptr;        // points to nothing
if (p != nullptr) {      // always check before dereferencing!
    cout << *p;
}

Your Task

Write tripleInPlace(int* p) that multiplies the value at the pointer by 3.
After tripleInPlace(&n) where n=4, n should be 12.

Back
cppCtrl+Enter to run
Output

Click "Run" to execute your code.