1

I ask this in relation to C as, in many senses, it's a precursor to C++.

Let's suppose that the pointer to member operator -> was replaced with .. Are there any instances when this would introduce ambiguity?

If not then why was an extra operator introduced? For such a terse language it seems an unnecessary extravagance.

Bathsheba
  • 231,907
  • 34
  • 361
  • 483
  • I wouldn't describe C as terse... – Will Vousden Dec 12 '13 at 12:31
  • I learnt 32 keyword C. Cf. VB. – Bathsheba Dec 12 '13 at 12:32
  • 1
    I think the spirit of C is to be explicit to the point that no boring detail is left implied, including automatic dereferencing for member access. Since there's a very important distinction in C between pointer variables and object variables, it makes sense to keep the syntax distinct. – Will Vousden Dec 12 '13 at 12:34

1 Answers1

2

ptr->member is just a simpler way to write (*ptr).member

H_squared
  • 1,251
  • 2
  • 15
  • 32