2011-01-10 176 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中看到過其他幾個人。