Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. C++ Course

Lesson 5 of 45 · C++

Lesson 13: Pointers Basics

Duration: 10 min

Pointers Basics\n\nPointers store the memory address of another object. A pointer is declared with the * suffix and can be assigned the address of a variable using the & (address‑of) operator.\n\n---\n\n## Example: Pointer declaration and dereferencing\ncpp\nint value = 42;\nint* ptr = &value; // ptr holds the address of value\nstd::cout << \"ptr points to \" << *ptr << \" (value)\\n\"; // dereference\n\n// Modify through pointer\n*ptr = 100;\nstd::cout << \"value is now \" << value << '\\n';\n\n\nPointers also support arithmetic for traversing arrays:\ncpp\nint arr[3] = {10, 20, 30};\nint* p = arr; // points to arr[0]\nstd::cout << *(p + 2) << '\\n'; // prints 30\n\n\n> Tip: Initialise pointers to nullptr when they do not point to a valid object. Dereferencing a null pointer yields undefined behaviour.\n\n---\n\n<Alert type="warning">Avoid raw pointers for ownership. Prefer smart pointers (unique_ptr, shared_ptr).\n

Previous: Lesson 12: C‑Style Strings and std::stringNext: Lesson 14: References