Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For future reference on Stack Overflow, copy-and-paste any and all compiler errors verbatim, and point out the line numbers in your code snippets.</p> <hr> <p>If you're new to C++, I highly, highly recommend that you <a href="https://stackoverflow.com/tags/c%2b%2b/info">pick up a good introductory C++ book</a> and read it. The C++ tag wiki here has a list of books recommended by the C++ community here on Stack Overflow.</p> <hr> <p>There are multiple issues with the code snippet you posted. Here's what I can see from visual inspection of the snippet:</p> <p>Change <code>typedef const T</code> to <code>typename T</code> and move the definition into the header:</p> <pre><code>class Constants { public: [...] template&lt;typename T&gt; static CString ToString(T value); { std::stringstream ss; // Note std:: prefix! ss &lt;&lt; value; CString csRow = ss.str().c_str(); return csRow; } }; </code></pre> <p>(You can also use <code>class T</code> instead of <code>typename T</code>; they are both equivalent in this case.)</p> <p>Ensure that the compiler can see the definition of <code>CString</code>. <a href="http://msdn.microsoft.com/en-us/library/5bzxfsea.aspx" rel="nofollow noreferrer">You may need to include <code>cstringt.h</code></a> if <code>stdafx.h</code> doesn't do that already.</p> <p>Also note that the standard library types live in the <code>std</code> namespace. That's why there's a <code>std::stringstream</code> there instead of simply a <code>stringstream</code>. You could also use <code>using namespace std;</code>, but do not ever use it in a header file.</p> <p>Avoid the use of <code>UPPERCASE NAMES</code> for variables and parameters; they are usually reserved for macros.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload