Is it possible to access member name from parameter
<p>Please consider this class:</p>

<pre><code>class A
{
public:       //public in this example
  string a1;
  string a2;
  string a3;
  string a4;
  int a5;
  double a6;
  (...) plus other 50 member names

  multiset&lt;string&gt; getAttrib(const vector(A)&amp; va, string attr)
  {
    for (vector&lt;string&gt;::const_iterator ci = va.begin; ci != va.end(); ++ci) {
      cout &lt;&lt; ci-&gt;attr &lt;&lt; endl;     //ERROR
  }
};
</code></pre>

<p>The member function could be called like:</p>

<pre><code>A a
a.getAttrib(vector_a, "a1");
</code></pre>

<p>This results in an error. <code>Const class A has no member named 'attr'.</code></p>

<p>I didn't want to write 50 different <code>case</code> statements to achieve the above wanted flexibility.
Is it possible somehow? 
And if member names are private can a public member function exist to perform this?</p>

<p>Besides <code>class A</code>, I have six other similar classes and wanted to have a parent class that would take a vector of any of the seven classes and could return the value (or in the real case a multiset) of the chosen membername.</p>
