title: Arbitrary data type in a C++ class
body: <p>I would like to make a class to store auxillary data in arbitrary objects - what is a clean way of doing this?</p>
  
  <pre><code>class A{
      std::string _name;
      int _val;
      void * _extraData;
  
      //I want to implement these methods
      void setExtraData(void * data){
          //
      }   
  
      void * getExtraData(){
      }   
  };
  
  
  class B{
      std::vector&lt;A *&gt; v;
  
      void foo(){
          //use A here - _extraData will      
          //be a (say) a vector&lt;int&gt;
      }
  };
  </code></pre>