title: Copy constructor invokes an infinite loop
body: <p>I am passing a value to copy constructor as a reference, but an infinite loop is being invoked.</p>
  
  <p>Here's my class:</p>
  
  <pre><code>class Vector2f{
  private:
      GLfloat x;
      GLfloat y;
  
  public:
      Vector2f();
      Vector2f(const GLfloat _x, const GLfloat _y);
      Vector2f(const Vector2f &amp;_vector);
  
      ~Vector2f();
  };
  </code></pre>
  
  <p>Here's implementation of methods:</p>
  
  <pre><code>Vector2f::Vector2f():
          x( 0.0f ),
          y( 0.0f )
  {
      DebugLog("Vector2f constructor");
  }
  
  Vector2f::Vector2f(const GLfloat _x, const GLfloat _y):
          x( _x ),
          y( _y )
  {
      DebugLog("Vector2f constructor(%f, %f)", _x, _y);
  }
  
  
  Vector2f::Vector2f(const Vector2f &amp;_vector):
          x( _vector.getX() ),
          y( _vector.getY() )
  {
      DebugLog("Vector2f copy constructor");
  }
  
  Vector2f::~Vector2f()
  {
  
  }
  </code></pre>
  
  <p>Here's how I access the class:</p>
  
  <pre><code>Vector2f tempVector1 = Vector2f(0.0f, 0.0f);
  DebugLog("tempVector1 initialized");
  
  Vector2f tempVector2;
  tempVector2 = Vector2f(0.0f, 0.0f);
  DebugLog("tempVector2 initialized");
  </code></pre>
  
  <p>The results I get are:</p>
  
  <pre><code>Vector2f constructor(0.000000, 0.000000)
  tempVector1 initialized
  Vector2f constructor
  Vector2f constructor(0.000000, 0.000000)
  Vector2f copy constructor
  Vector2f copy constructor
  Vector2f copy constructor
  ...
  </code></pre>
  
  <p>Infinite loop occurs when trying to initialize previously created object.
  If I try to copy tempVector1 into tempVector 2 an infinite loop occurs as well:</p>
  
  <pre><code>Vector2f tempVector2;
  tempVector2 = Vector2f(tempVector1);
  </code></pre>
  
  <p>Why does it happen and how can I prevent it from getting into an infinite loop?</p>
  
  <p>Thank you in advance.</p>