title: Problem creating instance of a class
body: <p>I've create the following class in Visual Studio 2010:</p>
  
  <pre><code>public class Bat : Form1
      {
          public int BatLocation;
  
          public void draw()
          {
              Pen batPen = new Pen(Color.Black);
              batPen.Width = 10;
              playArea.DrawRectangle(batPen, BatLocation, (picPlayArea.Height - 30), 50, 10);
          }
      }
  </code></pre>
  
  <p>But when I try to create an instance of the class, I get a stack overflow exception, advising me to make sure that I don't have an infinite loop or infinite recursion. I have tried creating the instance two different ways, as below:</p>
  
  <pre><code>Bat bottomBat;
  bottomBat = new Bat();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Bat bottomBat = new Bat();
  </code></pre>
  
  <p>But both ways return the same error when I try to run the program. I've also tried the class definition with and without the <code>public</code> modifier.</p>
  
  <p>I'm pretty new to programming and have no idea what might be causing this problem. Am I doing something wrong?</p>
  
  <p><strong>Edit:</strong> The code for the <code>Bat</code> class is everything I have at the moment, haven't created a specific constructor for it... Didn't think I needed to?</p>
  
  <p>Anyway, here is the Form1 class in its entirety:</p>
  
  <pre><code>public partial class Form1 : Form
      {
          // Define various objects for the game
          public Graphics playArea;
          Bat bottomBat = new Bat();
  
  
          public Form1()
          {
              InitializeComponent();
  
              // Create instances of objects
              playArea = picPlayArea.CreateGraphics();
              //bottomBat = new Bat();
  
              // Delegate the mouseMove event for picPlayArea
              picPlayArea.MouseMove += new MouseEventHandler(picPlayArea_MouseMove);
  
  
          }
  
          private void picPlayArea_MouseMove(object sender, MouseEventArgs e)
          {
              bottomBat.Location = e.X;
          }
  
          private void btnExit_Click(object sender, EventArgs e)
          {
              string msg = "Are you sure you want to exit?",
                     title = "Confirm Exit";
  
              DialogResult res = MessageBox.Show(msg, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
              if (res == DialogResult.Yes)
              {
                  Environment.Exit(0);
              }
          }
  
          private void timer1_Tick(object sender, EventArgs e)
          {
              // This is where most of the functionality is executed within the game
              playArea.Clear(Color.White);
          }
  
          private void btnStart_Click(object sender, EventArgs e)
          {
              timer1.Enabled = true;
          }
      }
  </code></pre>