C++ Pointer Memory Question
cheesehumble (0)

I created a linked list class which only contains one member:
Node* head;

If I create a pointer a created LinkedList object why do I need to add 4 to the pointer to grab the head variable?

You are viewing a single comment. View All
a5rocks (774)

1) pointer operations like that arent very good (in my opinion, though I dont do C++...)
2) C++ structs / objects / whatever in the memory have themselves, then their fields. So you just locate where it is in memory and then add 4 to get the first field.