所以这可能是我最近看到的最奇怪的事情,并且很好奇这是怎么发生的。编译器给我一个错误,说 std::string 在用作返回类型时是未定义的,但在用作类方法中的参数时则不是!
#pragma once
#include <string>
#include <vector>
// forward declarations
class CLocalReference;
class CResultSetHandle;
class MyClass
{
public:
MyClass() {}
~MyClass {}
void Retrieve(const CLocalReference& id, CResultSetHandle& rsh, std::string& item); // this is fine
const std::string Retrieve(const CLocalReference& id, CResultSetHandle& rsh); // this fails with std::string is undefined?!?!
};
重建所有它仍然发生我不得不选择干净的解决方案,然后在宇宙重新对齐之后再次重建所有。虽然目前已解决,但我仍然想知道是什么原因造成的,因为我不知道为什么什么时候不应该有冲突,尤其是当我总是为 STL 使用完全限定的名称时。
最佳答案
这可能是一个编译器错误。我在 VS2010 中看到了其他几个。
关于c++ - Visual Studio 2010 使用 std::string 编译错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4649178/