Veda Bites are swipeable micro-lessons — each one teaches exactly one
idea. The bites below come from this kit — swipe through them in the app.
💡 Key Idea
Arrow Operator = Dereference + Dot
One symbol replaces two operations.
The arrow operator `->` is a shortcut that does two things at once: it dereferences a pointer and then accesses a member.
↳ `ptr->member` is exactly the same as `(*ptr).member` — just cleaner to write and read.
📖 Definition
What Exactly Is the Arrow Operator?
A pointer's personal member-access tool.
↳ Left side must be a pointer; right side must be a member name.
💡 Key Idea
Why the Arrow Operator Exists
Because (*ptr).name gets ugly fast.
↳ It exists purely for cleaner, safer pointer member access.
💻 Code Example
Basic Arrow Operator in Action
See it work in 5 lines.
↳ `ptr->roll` reads the `roll` member of the struct that `ptr` points to.
⚖️ Comparison
Dot vs Arrow: When to Use Which
Object or pointer? That decides it.
↳ Object → dot. Pointer → arrow. Never mix them up.
⚠️ Common Mistake
Mixing Up Dot and Arrow
The #1 beginner pointer slip.
↳ If the left side is a pointer, you must use `->`.
⚠️ Common Mistake
Forgetting Parentheses in (*ptr).member
Precedence bites without brackets.
↳ This precedence trap is exactly why the arrow operator was introduced.
⚙️ Process
How to Use the Arrow Operator
Four steps to pointer access.
↳ Pointer must hold a valid address before you can use `->`.
💡 Use Case
Where the Arrow Operator Shines
Linked lists live on this operator.
↳ Any data structure built from pointers relies heavily on `->`.
✏️ Example
Linked List Node Traversal
Walk a list with one symbol.
↳ `temp->next` moves you to the next node cleanly.
🧠 Memory Trick
Remember It as 'Pointer Points'
Arrow = pointer pointing at a member.
Think of `->` as an arrow pointing from the pointer to the member it wants. If there's a pointer on the left, an arrow is the natural choice.
↳ Pointer on the left → arrow on the right.
🎯 Exam Tip
Exam Favourite: Rewrite the Expression
Exams love the (*ptr).x ↔ ptr->x swap.
↳ Master the equivalence — it appears in almost every pointer question.
🚫 Warning
Never Use Arrow on a NULL Pointer
NULL + arrow = crash.
↳ Arrow dereferences — so the pointer must be valid first.
❓ Did You Know
Arrow Works on Class Pointers Too
Not just structs — classes too.
In C++, `->` also accesses member functions of a class through a pointer, e.g. `objPtr->display();` — not just data members.
↳ In C++, `->` handles both data and methods through pointers.
✅ Best Practice
Prefer Arrow Over (*ptr).member
Cleaner code, fewer bugs.
↳ Arrow is the idiomatic, readable choice for pointer member access.