Enumerate members of a structure?

前端 未结 6 943
渐次进展
渐次进展 2021-01-13 10:02

Is there a way to enumerate the members of a structure (struct | class) in C++ or C? I need to get the member name, type, and value. I\'ve used the following sample code b

6条回答
  •  误落风尘
    2021-01-13 10:22

    Since C++ does not have reflection builtin, you can only get the information be teaching separately your program about the struct content.

    This can be either by generating your structure from a format that you can use after that to know the strcture information, or by parsing your .h file to extract the structure information.

提交回复
热议问题