Values & References6 / 16
Up next

Dereference and address-of

#include <print>

int main() {
    int n = 10;
    int* p = &n;
    // read through the pointer, then call a value through it
    std::println("{}", *p + 1);
    // members of a pointed-to object use ->
    std::string s = "hi";
    std::string* sp = &s;
    std::println("{}", sp->size());
}
What you're solving

& makes a pointer, * follows it