Purpose of struct, typedef struct, in C++

前端 未结 6 693
失恋的感觉
失恋的感觉 2020-12-03 05:43

In C++ it is possible to create a struct:

struct MyStruct
{
    ...
}

And also possible to do the following:

typedef struct         


        
6条回答
  •  [愿得一人]
    2020-12-03 06:11

    The "struct MyStruct { };" construct implicitly defines the equivalent typedef, so typically that would be the preferred modern usage. There are still some uses for a typedef, mainly with pointer types to structures. E.g.

    typedef struct MyStruct* MyStructPtr;
    

提交回复
热议问题