15

I checked that the protected access specifier can be used inside class, struct as well as union. I know that the protected access specifier means that members will be private, but visible to derived class. I am not able to think of a reasonable use case where the protected keyword inside a union would be useful, because a union can't be part of an inheritance hierarchy. Since in a union private and protected would make no difference, why allow protected inside unions too?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
anonymous
  • 1,920
  • 2
  • 20
  • 30

1 Answers1

15

I'd say the real question is the opposite, why disallow it? Yes, it's synonymous to private in this case, but would it really be worth the (albeit minor) complication of the language and compiler implementation? It doesn't hurt in any way, either.

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455