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;
Now, I want to programmatically get the field names and type of obj
. Is it possible?
This is C++ BTW.
You are asking for Reflection in C++.
I'm afraid you cannot get the field names, but you can get the type of obj using Boost.Typeof:
#include <boost/typeof/typeof.hpp>
typedef BOOST_TYPEOF(obj) ObjType;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With