title: C++ printing a static const class
body: <p>I am trying to learn c++ and am creating a Vector2 class. I have this ToString() function in my Vector2 class which would allow me to print a Vector2 to the screen.</p>
  
  <p>I also have this static const Vector2 variable called up, and I also want to print them using this ToString() function But it's giving an error. 
  This is the Vector2::up implementation in .h and .cpp </p>
  
  <p>When I store the Vector2::up in a Vector2 vec and print it like vec.ToString(), it works.
  But When i try to print Vector::up.ToString() it doesn't work. </p>
  
  <p>This is what is in my Vector2 class, the Vector2::up and the ToString() Function.</p>
  
  <pre><code>"Vector2.h"
  
  static const Vector2 up;
  
  std::string ToString (int = 2);
  
  
  "Vector2.cpp"
  
  const Vector2 Vector2::up = Vector2 (0.f, 1.f);
  
  std::string Vector2::ToString (int places)
  {
      // Format: (X, Y)
      if (places &lt; 0)
          return "Error - ToString - places can't be &lt; 0";
      if (places &gt; 6)
          places = 6;
  
      std::stringstream strX; 
      strX &lt;&lt; std::fixed &lt;&lt; std::setprecision (places) &lt;&lt; this-&gt;x;
      std::stringstream strY;
      strY &lt;&lt; std::fixed &lt;&lt; std::setprecision (places) &lt;&lt; this-&gt;y;
  
      std::string vecString = std::string ("(") +
                              strX.str() +
                              std::string (", ") +
                              strY.str() +
                              std::string (")");
  
      return vecString;
  }
  </code></pre>
  
  <p>What i would like to do in my Main Function</p>
  
  <pre><code>"Main.cpp"
  
  int main ()
  {
      Vector2 vec = Vector2::up;
      cout &lt;&lt; vec.ToString () &lt;&lt; endl;
      cout &lt;&lt; Vector2::up.ToString () &lt;&lt; endl;
  
      cout &lt;&lt; endl;
      system ("pause");
      return 0;
  }
  </code></pre>
  
  <p>And I would like them to both print (0.00, 1.00) but the Vector2::up.ToString() is giving an error</p>
  
  <pre><code>1&gt;c:\users\jhehey\desktop\c++\c++\main.cpp(12): error C2662: 'std::string JaspeUtilities::Vector2::ToString(int)': cannot convert 'this' pointer from 'const JaspeUtilities::Vector2' to 'JaspeUtilities::Vector2 &amp;'
  </code></pre>