c++ - Visual Studio 2010 使用 std::string 编译错误?

标签 c++ visual-studio-2010 stl stdstring

所以这可能是我最近看到的最奇怪的事情,并且很好奇这是怎么发生的。编译器给我一个错误,说 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/

相关文章:

c# - View 和 View 模型之间的快捷方式(Visual Studio 2012)

c++ - 如何以 STL 方式将一定数量的字符从文件复制到 vector ?

c++ - 在恒定的 O(1) 时间内连接 2 个 STL vector

c++ - __LP64__ 在哪里为 OSX 10.6 上的 C++ 应用程序的默认构建定义?

c++ - g++找不到boost头文件

c++ - Facebook 如何处理他们的数据库信息?

c# - Visual C# 2010 Express 在调试后保留文件句柄

c# - 如何判断一个方法是直接还是间接调用了一个属性?

c++ - 编译 gcc/g++/libstdc++ 时的 --enable-threads=LIB 是什么意思?

c++ - 为什么这个c++程序会导致系统崩溃?