title: Difference between declaring static object and pointer to static object
body: <pre><code>    #include &lt;iostream&gt;
      using namespace std;
      class First{
          public:
          void fun()
          {
              cout&lt;&lt;"base fun called\n";
          }
      };
  
      class Second{
          public:
          static First x; //Line 1
          static First *y; //Line 2
      };
  
      First Second::x; //Line 3
  
      First* Second::y; //Line 4
  
      int main()
      {
          Second::x.fun();
          Second::y-&gt;fun();
          return 0;
      }
  </code></pre>
  
  <p>Line 1 and Line 2 are declarations and Line 3 and Line 4 are definitions, this I have understood from some other stackoverflow posts about static members.</p>
  
  <p>Q1. Why we have to define static objects like this ? (Line 3 and line 4)</p>
  
  <p>Q2. Whats difference between x and y?(Line 1 and Line 2)</p>
  
  <p>Q3. Where is the memory allocated for x and y objects ?(Line 3 and Line 4)</p>