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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Lesson 13: Pointers Basics | C++ Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. C++ Course

Lesson 13 of 45

·C++

Lesson 13: Pointers Basics

10 min

Course progress29%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • Pointer declaration and initialization
  • The address‑of operator (&)
  • Dereferencing (*) and accessing pointed data
  • Pointer arithmetic fundamentals

Pointers Basics

Pointers 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.


Example: Pointer declaration and dereferencing

int value = 42;
int* ptr = &value;        // ptr holds the address of value
std::cout << \"ptr points to \" << *ptr << \" (value)\
\"; // dereference

// Modify through pointer
*ptr = 100;
std::cout << \"value is now \" << value << '\
';

Pointers also support arithmetic for traversing arrays:

int arr[3] = {10, 20, 30};
int* p = arr; // points to arr[0]
std::cout << *(p + 2) << '\
'; // prints 30

Tip: Initialise pointers to nullptr when they do not point to a valid object. Dereferencing a null pointer yields undefined behaviour.


<Alert type="warning">Avoid raw pointers for ownership. Prefer smart pointers (unique_ptr, shared_ptr).

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from C++ CourseBrowse activities
Previous lessonLesson 12: C‑Style Strings and std::stringContinue to lesson 14Lesson 14: ReferencesBack to C++ Course curriculum