Skip to content
Learn Netverks

Lesson

Step 18/36 50% through track

pointers-cpp

Pointers in C++

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Pointers in C++: the syntax, patterns, and safety habits you need before advancing in C++.

Teams still ship Pointers in C++ in C++ codebases—skipping it leaves gaps in debugging and code reviews.

You will apply Pointers in C++ in contexts like: Game engines, trading systems, desktop apps, and performance-critical libraries.

Write C++ in main.cpp with int main(), click Run on server—the dev runner compiles with c++/g++ -std=c++17 -Wall and runs the binary; read template errors in stderr (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

C++ inherits pointers from C: variables that store addresses. Use pointers for optional/nullable indirection, C APIs, and low-level code—but prefer references and smart pointers in application logic.

Basics

int x = 42;
int* p = &x;
std::cout << *p << "\n";  // 42

Use nullptr instead of NULL or 0 for null pointers in modern C++.

Important interview questions and answers

  1. Q: Pointer vs reference?
    A: Pointers can be null and reseated; references must bind to valid objects.
  2. Q: When still use raw pointers?
    A: Non-owning observers, C interop, and legacy APIs—document ownership clearly.

Self-check

  1. What does *p do?
  2. Preferred null pointer constant in C++11+?

Tip: Use nullptr not NULL or 0—compare with C pointer habits but modernize null checks.

Interview prep

What is nullptr?

Type-safe null pointer constant in modern C++—prefer over NULL or 0.

When use raw pointers?

Non-owning observers, C API interop, and legacy code—document ownership clearly.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • nullptr vs NULL?
  • Raw ptr still?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump