In python, there is a function called getattr which would look like this:
class MyObject():
def __init__(self):
self.xyz = 4
obj = MyObject()
getattr(obj, 'xyz')
where the call to getattr would return 4.
Is there a similar way to do this in C++ (Not Visual C++)?
Are there any libraries that have this functionality where I can lookup an object's member variables using a string?
I am trying to find a way to look up public data members in a C++ class that I cannot change. So I cannot use a map to map string literals to values. Maybe like an 'unstringify' with macros?