Tsallaka zuwa abun ciki
Justice Tech School

Pointers

A pointer stores an address. Use nullptr for empty and prefer smart pointers for owning.

Example
#include <iostream>

int main() {
  int x = 10;
  int *p = &x;
  *p = 20;
  int *q = nullptr;
  std::cout << x << " " << (q == nullptr) << "\n";
  return 0;
}

Result

20 1

Exercise

Empty pointer.

int *p = ;

Quiz Test

What is nullptr?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.