我想我遇到了一个(可能) VC6 (我知道)。这是我们所用的。编译器错误,但我很开放,我刚刚错过了一些愚蠢的东西。给出以下代码(这只是一个例子!):
#include <iostream>
// Class with template member function:
class SomeClass
{
public:
SomeClass() {};
template<class T>
T getItem()
{
return T();
};
};
// Dummy just used to recreate compiler err
下面的代码适用于Visual C++ 2008。然而,当涉及到Visual C++ 6时,我得到了以下错误。我可以知道为什么,以及我如何修复这个错误,但仍然使析构函数保持私密。
class X
{
public:
static X& instance()
{
static X database;
return database;
}
private:
X() {} // Private constructor
~X() {} // Pri
我想把CString转换成字符串。(是的.我知道我在做什么。我知道如果ANSI值范围在ANSI值范围之外,返回的字符串将是不正确的,但这没问题!)
以下代码将在VC2008下工作。
std::string Utils::CString2String(const CString& cString)
{
// Convert a TCHAR string to a LPCSTR
CT2CA pszConvertedAnsiString (cString);
// construct a std::string using the LPCSTR input