m14-mental-model

star 13

C++ Mental Models: Pointer vs Reference, Initialization, Undefined Behavior.

13eholder By 13eholder schedule Updated 1/25/2026

name: m14-mental-model description: "C++ Mental Models: Pointer vs Reference, Initialization, Undefined Behavior."

C++ Mental Models

Core Question

What happens in memory?

  • Value: Does it own the bytes?
  • Reference: Is it an alias?
  • Pointer: Is it nullable?

Thinking Prompt

  1. Is it a Copy or Reference?

    • auto x = y (Copy).
    • auto& x = y (Reference).
  2. Does it dangle?

    • Returning &local is always wrong.

Quick Reference

Concept Mental Model
T& Guaranteed Alias.
T* Nullable Address (Requires check).
std::move Cast to rvalue (Prepare to steal).
Install via CLI
npx skills add https://github.com/13eholder/Modern-Cpp-Skills --skill m14-mental-model
Repository Details
star Stars 13
call_split Forks 3
navigation Branch main
article Path SKILL.md
More from Creator