1

How to loop (foreach public variable of class in c++), I have temp_class like the following

  class temp_class
    {
    public:
    std::string name;
    int age;
    class2 object_class;

    private:
    //some code here
    }

Now I need to get a list of all public variable in the class (some thing similar if we want to get a list of all the properties of a c# class, but for c++ class)

temp_class object_class;
//here these is a code to set the values for each public variable in the object

foreach(public_variable in object_class)
{
  string var_name=//get the public variable name
  string var_value=//get the public variable value
}
Hazem Abdullah
  • 1,837
  • 4
  • 23
  • 41

1 Answers1

0

You can't. this is C++ , unmanaged code without true reflection.

David Haim
  • 25,446
  • 3
  • 44
  • 78