2 C enum questions -


part 1

In C, there is no difference in making a declaration Anonym is like this:

  typingf enum {VAL1, VAL2,} firstEnum;  

And so on:

  enum secondEnum {Val1, Val2,};  

Apart from the fact that while using the second Annam, you have to write:

  enum secondEnum ...;   

Part 2

Also, am I right in thinking that the following is equivalent:

  Enum {Val1, Val2,} enum1;  

and

  enum third enum {val1, val2,} enum thirdEnum enum1;  

thanks

In part 1, clearly a difference - First you are announcing firstEnum as typedef for the (anonymous) enumerated type, while the second secondEnum is enumerated in type Tag is not included and it does not contain the typewriter for the first time the ease of use is recommended as you have noted.

In Part 2, both are not equal - first announces an anonymous animated type and defines enum1 , declares the second designated enumerated type of that type, and then To be like that, enum1 declares to be. The importance is that you can use the named type in the other parts of the code, whereas in the first you can not use it somewhere, then you might be able to use the integer values ​​as the other names for enumerated type values Will happen.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -