Difference between Dot(.) and Arrow (*) in C language | ||||||||
Representation | ||||||||
Dot (.) | Arrow (*) | |||||||
The Dot (.) operator can't be overloaded. | Arrow (->) operator can be overloaded. | |||||||
ex:(*foo).bar() | ex:foo->bar() | |||||||
Note1: The parenthesizes above are necessary because of the binding strength of the * and . operators. | ||||||||
Note2: *foo.bar() wouldn't work because Dot (.) operator binds stronger and is executed first. | ||||||||
Possible way of dot and arrow usage for non pointer element in C. | ||||||||
ptr->fld == (*ptr).fld | ||||||||
str.fld == (&str)->fld |
Saturday, December 15, 2012
Difference between Dot(.) and Arrow (*) in C language
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment