Advertisement

-> operator

Started by January 01, 2003 04:42 PM
2 comments, last by Tac-Tics 21 years, 10 months ago
Question: is the -> operator defined by C compilers or was it invented later for ease of pointer use in C++? "You TK''ed my chicken!"
The -> operator is used with classes so that you don''t have to do (*Class).member, and since classes don''t exist in C, I would asssume that the answer is no.

Brendan
Brendan"Mathematics is the Queen of the Sciences, and Arithmetic the Queen of Mathematics" -Gauss
Advertisement
The -> operator is also used with structs and unions. It wasn''t invented for C++, it was inherited from C.
Spock is correct, as usual. :D

Classes are sort of like fancy structures. In C, you use -> to reference members of a structure using its pointer:

pMyStructure->variable = 0;

Where pMyStructure is a pointer to a structure and variable is a member of that structure.

This topic is closed to new replies.

Advertisement