Path: utzoo!utgpu!attcan!uunet!husc6!cmcl2!adm!stanonik@nprdc.arpa From: stanonik@nprdc.arpa (Ron Stanonik) Newsgroups: comp.unix.questions Subject: why p->member ? Message-ID: <16734@adm.ARPA> Date: 4 Aug 88 14:35:01 GMT Sender: news@adm.ARPA Lines: 21 While explaining pointers to structures someone asked why the -> operator was needed; ie, why couldn't the members be referenced as p.member. My first response was, we're talking about pointers to structures, not structures, so a separate operator is needed. On second thought though, since the compiler knows whether the variable is a pointer or structure, why shouldn't the compiler do the "right" thing when it sees p.member? Could this ever be ambiguous? That is, is there some declaration of p such that p could be interpreted as both a structure and a pointer to a separate structure. I tried fiddling around with unions, but could not produce such an object. Does it make a lot more work for the compiler? It doesn't seem so, since it's already keeping track of p's type. Thanks, Ron Stanonik stanonik@nprdc.arpa