title: How to enforce a static member on derived classes?
body: <p>I have a base class, <code>Primitive</code>, from which I derive several other classes--<code>Sphere</code>, <code>Plane</code>, etc.</p>
  
  <p><code>Primitive</code> enforces some functionality, e.g <code>intersect()</code>, on its subclasses through pure virtual functions. The computation of <code>intersect</code> depends on instance data, so it makes sense to have it as a member method.</p>
  
  <p>My problem arises in the following:
  I want every derived instance to be able to identify its type, say through a <code>std::string type()</code> member method. As all instances of the same class will return the same type, it makes sense to make <code>type()</code> a <code>static</code> method. As I also want every <code>Primitive</code> subclass to implement this method, I would also like to make it a pure virtual function, like <code>intersect()</code> above.</p>
  
  <p>However, static virtual methods are not allowed in C++.
  <a href="https://stackoverflow.com/questions/1820477/c-static-virtual-members">C++ static virtual members?</a>
  and
  <a href="https://stackoverflow.com/questions/7227236/can-we-have-a-virtual-static-method-c">Can we have a virtual static method ? (c++)</a>
  ask similar questions but they do not include the requirement of enforcing the function on derived classes.</p>
  
  <p>Can anyone help me with the above?</p>