2011-01-10 174 views
1

所以这可能是我最近看到的最奇怪的事情,并且很好奇这是如何发生的。编译器给了我一个错误,说std :: string在作为返回类型使用时是未定义的,但是在用作类的方法中的参数时没有定义!Visual Studio 2010与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的完全限定名称时。

+0

可否请您粘贴原始错误? – 2011-01-10 16:51:22

+0

析构函数应该是 `〜MyClass(){}` 除此之外,它对我来说编译得很好。我想这是一个VS2010的错误,或者错误是在你的代码中的其他地方。 (你知道,*甚至是微软*会产生错误!!) – Oystein 2011-01-10 16:54:38

回答

0

这可能是一个编译器错误。我在VS2010中看到过其他几个人。