title: C++ using static array in base class, declaring in derived class
body: <p>I'm trying to create a few classes which all are derived classes from an abstract class (lets call it) <em>BaseClass</em>. In BaseClass I want to operate on <strong>static</strong> variables (arrays) declared in derived classes. Is there a clever way in C++ to let the compiler know that static variable will be declared in derivered class? Or should I,  for instance, in my derived classes' constructors pass a reference to a static variable to base class construct? This is my idea:</p>
  
  <pre><code>class BaseClass
  {
     std::vector&lt;float&gt; &amp;vector;
  
  public:
     BaseClass(std::vector&lt;float&gt; &amp;dVector):vector(dVector){};
  
     void vectorOperation()
     {
         vector.doSomething();
     }
     ...     
  }
  
  class DerivedClass : public BaseClass
  {
     static std::vector&lt;float&gt; sVector;
     DerivedClass():BaseClass(sVector){};
     ... 
  }
  </code></pre>
  
  <p>Is my solution correct? Is there any better way to do this? </p>