Simple Games using ncurses
Menu
Question:
what does -> really mean? In basic calculator programming, 21->A means 21 if assigned to A. I know that it is a pointer related thing but just not really getting it. Answer: Forget what you know about calculator programming.-> means something completely different in C. -> is a token (don’t think of it as “minus-greater-than”, think of it as “arrow”) that takes a pointer on its left side and a sub-field on its right side: instance -> member It’s like instance is a “container” while member is a variable within that container. Also, -> is syntax sugar for dereferencing a pointer and accessing its field, i.e. instance -> member is the same as *(instance) . member Generally, both -> and . will only work on structs/unions and objects (class instances).
0 Comments
Leave a Reply. |
Archives
March 2016
Categories |