</>
Skip to content
C++ lessons (22/42)

C++ — Pointers

Declare pointer

int x = 10;
int *ptr = &x;

Dereference

cout << *ptr << endl;  // 10

Null pointer

int *ptr = nullptr;

Pointer arithmetic

int arr[] = {1, 2, 3};
int *ptr = arr;
cout << *(ptr + 1) << endl;  // 2

Mini Practice

  1. Declare pointers
  2. Dereference pointers
  3. Use pointer arithmetic
  4. Practice with arrays

Up Next

Continue with References - Reference types.

Related Topics

Frequently Asked Questions about Pointers

What is Pointers in C++?

Pointers is a fundamental concept in C++. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Pointers?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Pointers.

Why is Pointers important in C++?

Pointers is essential for C++ development. Understanding this concept will help you write better code and solve real-world problems more effectively.