Hi, I'm reading one C++ book and in one example there was this very weird typedef that I have no idea how to use and what exactly does it mean. It was not the important part of the example so its not mentioned anymore.
So here it is
typedefenum {red, green, blue} *ptrColor;
So I'm looking at it and I have no idea how this ptrColor could actually be used somewhere. That enum is unnamed so how exactly am I supposed to create any instance of that enum if all I have is pointer to that enum and nothing more?
I believe that an enum like that will export its names to the surrounding scope, so you can just use "red" directly. That said, I don't know how you could instantiate such an object without being able to name it.
Perhaps you could cheat with something like auto aColor = red;?
Yea good one, that works :D Tnx a lot man. The book I saw it in was actually C++ Templates The Complete Guide and of course its a very old book. I wonder how it could be used back then without auto.
You kind of answered my question but I'll leave this unanswered for a moment just to see if someone could tell something about any real use of this interesting typdef :)
Tnx man for making this clear. I actually thought that besides making this point (point 2) this enum pointer was actually useful in some situations. I was wrong but thanks very much man! :)