dimanche 9 février 2020

Variable name after struct definition

What are bar and x below and why are they located there? Are they instances of the structs?

I was reading this Stackoverflow question whose code I have pasted here and I found that the poster and one of the answers use variable names [bar and x] after the definition of the struct. cpp reference doesn't use this syntax their examples and I don't know what the syntax is called nor what the syntax does to look it up.

If it is just about creating an instance of a struct, why not write it in the next line like cpp reference does in its examples?

struct _bar_ 
    {
        int a;
    } bar; 
struct test {
      int value;
   } x;

Aucun commentaire:

Enregistrer un commentaire