title: C++ identify data structure from adress
body: <p>I would like to know if there is a way in C++ to know in what data structure an address is. For example, I have a base class (A) that has two inherited class (B and C). In a fourth class (D), I have two vectors of the STL, one containing pointers of B, the second containing pointers of C.</p>
  
  <p>In D, I am implementing a method that is withdrawing an object A. In that method, I am using another implemented function of D that is searching in the vectors if the object A is there and return a pointer to this object.</p>
  
  <p>Is there a way after that to manipulate the appropriate vector of where the object A to directly delete it from the vector (knowing in what vector it is and its position in the vector) ?</p>
  
  <pre><code>A* D::findA(string word)
  {
      for (unsigned int i = 0; i &lt; vectorOfB_.size(); i++) {
          if ( vectorOfB_[i]-&gt;getWord() == word)
              return vectorOfB_[i];
      }
  
      for (unsigned int i = 0; i &lt; vectorOfC_.size(); i++) {
          if (vectorOfC_[i]-&gt;getWord() == word)
              return vectorOfC_[i];
  }
  
  bool D::withdrawA(string word)
  {
      A* obj = findA(word);
      if (obj != nullptr) {
      }
      return false;
  }
  </code></pre>
  
  <p>At this point, I know that the method found the object A, I know its address, but I don't know in what vector it is. I would like to use the erased() method of the STL vector class to withdraw it from the vector, but without doing loops again to go check in the vectors.</p>