title: Derived classes of abstract class in an Array
body: <p>Good day everyone.</p>
  
  <p>I have a question about making and using derived classes of some base abstract class.</p>
  
  <p>I can't quite understand how it works.</p>
  
  <p>My goal: Make a basic class that will define what functions there should be, and then create different derived classes. Then to make an array of base class and instantiate in it different derived classes.</p>
  
  <p>For example:</p>
  
  <pre><code>abstract class UIElement
  {
      //constructor
      abstract public UIElement();
      //draw element
      abstract public void Draw(int mouseX, int mouseY);
      //checks if the element is pointed at by mouse
      abstract public Boolean IsPointed(int mouseX, int mouseY);
      //defines what happens when clicked
      abstract public void Click(int mouseX, int mouseY);
      //destructor
      abstract public ~UIElement();
  }
  </code></pre>
  
  <p>Then create several derived classes and do like that:</p>
  
  <pre><code>UIElement[] qwe = new UIElement[3];
  qwe[0] = new UIElementButton();
  qwe[1] = new UIElementLabel();
  qwe[2] = new UIElementSomethingElse();
  </code></pre>
  
  <p>1) What is the proper way to do it, because I can't find a definitive answer or an article that would explain it...</p>
  
  <p>2) About class variables, where they should be declared: base class or derived?</p>
  
  <p>3) What if different derived classes have different variables, how that should be addressed?</p>
  
  <p>4) Can derived classes have different constructor including different arguments?</p>