title: Using vector of different Objects
body: <p>I am trying to make a vector of objects with different variables, can find how to access variables that are not in the base class.</p>
  
  <pre><code>struct X {
      string name;
   };
  
   struct Y : X {
      int num;
      void Set_Num(int a)
      {
         num = a;
      }
   };
  
   int main()
   {
         vector&lt;X*&gt; v;
         v.push_back(new Y);
         v[0]-&gt;name="It"; //I can access name but not num
        // v[0]-&gt;Set_Num(10);
   }
  </code></pre>