从其对象获取struct字段的名称和类型 [英] Getting name and type of a struct field from its object
本文介绍了从其对象获取struct字段的名称和类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我有一个这样的结构:
For example, I have a struct which is something like this:
struct Test
{
int i;
float f;
char ch[10];
};
我有一个此结构的对象,例如:
And I have an object of this struct such as:
Test obj;
现在,我想以编程方式获取字段名称和类型 obj
。可能吗?
这是C ++ BTW。
This is C++ BTW.
推荐答案
正在要求 C ++中的反射。
这篇关于从其对象获取struct字段的名称和类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文