Structure tag and name, why does a local variable declared as name compile?

In some code I saw recently there was a structure defined like this:

typedef struct tagMyStruct {
    int numberOne;
    int numberTwo;
} MYSTRUCT;

The way I understand this, tagMyStruct is the new data type and MYSTRUCT is a variable that is created right there.

At another place, this was used like this:

MYSTRUCT *pStruct = new MYSTRUCT;

and it compiled fine with Visual Studio 2010. How is that valid C++? I thought MYSTRUCT was a variable and not a type?

7
задан bastibe 2 December 2010 в 11:54
поделиться