title: " undefined reference to `toppers::recordTop' " error?
body: <p>My problem was:
  Write a program that has a class Student to store the details of students in a class. Derive another class Toppers from the Student that stores records of only top 3 students of the class</p>
  <p>Here, In the inherited class toppers , I have take taken a data member(recordTop[3]) of derived class(Toppers) and initialised it in top3(toppers a[], int n) function but yet it giving me an error of  undefined reference to `toppers::recordTop' .</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  using namespace std;
  
  class students
  {
      protected: 
      string name;
      int total;
      public:
          void input_students()
          {
              cout &lt;&lt; &quot;Enter your Name : &quot;;
              cin &gt;&gt; name;
              cout &lt;&lt; &quot;Enter your total marks : &quot;;
              cin &gt;&gt; total;
          }
  
          void output_students()
          {
              cout &lt;&lt; &quot;Name : &quot; &lt;&lt; name &lt;&lt; endl;
              cout &lt;&lt; &quot;Total Marks : &quot; &lt;&lt; total &lt;&lt; endl;
          }
  };
  
  class toppers : public students
  {
      protected:
      static toppers recordTop[3];
  
      public :
          friend void sort(toppers a[], int n)
          {
              for (int i = 0 ; i &lt; n ; i++)
              {
                  for (int j = i ; j &lt; n ;j++ )
                  {
                      if(a[j].total &gt; a[i].total)
                      {
                          toppers temp = a[j];
                          a[j] = a[i];
                          a[i] = temp;
                      }
                  }
              }
          }
  
          void top3(toppers a[], int n)
          {
              recordTop[0] = a[0];
              recordTop[1] = a[1];
              recordTop[2] = a[2];
          }
  
          void output_toppers()
          {
              for (int i = 0; i&lt;3 ; i++)
              {
                  cout &lt;&lt; &quot;Details of RANK &quot; &lt;&lt; i + 1 &lt;&lt; &quot; are : &quot; &lt;&lt; endl;
                  recordTop[i].output_students();
              } 
          }
  };
  
  
  int main()
  {
      int n;
      cout &lt;&lt; &quot;Enter number of students : &quot;;
      cin &gt;&gt; n;
  
      toppers st[n];
  
      for (int i = 0; i &lt; n ; i++)
      {
          st[i].input_students();
      }
  
      sort(st,n);
  
      st[0].top3(st, n);
      st[0].output_toppers(); 
      return 0;
  }
  </code></pre>
  <p>If possible , please point my mistake?</p>