title: How to get struct member with a string using Macros C++
body: <p>Consider the following example:</p>
  
  <pre><code>struct MyStruct {
      int a;
      int b;
  };
  </code></pre>
  
  <p>I can use macros to set a member from an instance of the struct by doing this:</p>
  
  <pre><code>#define setVar(x,y) instance.x = y
  </code></pre>
  
  <p>then in any function I can say:</p>
  
  <pre><code>setVar(a, 4)
  </code></pre>
  
  <p>How can I send in a as a string to the macro? Is that also possible?</p>
  
  <pre><code>setVar("a", 4)
  </code></pre>
  
  <p>EDIT: There are a bunch of predefined structs with members that are all of type double. I only know what struct I am using by an XML config file that is passed in. After parsing, I have a bunch of strings that are a list of all the data members and values that need to be set. I need to use this list to set values for each of the members in the struct.</p>