Visual Studio 2010 compile error with std::string?

Posted by AJG85 on Stack Overflow See other posts from Stack Overflow or by AJG85
Published on 2011-01-10T16:48:04Z Indexed on 2011/01/10 16:54 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

So this is possibly the strangest thing I've seen recently and was curious how this could happen. The compiler gave me an error saying that std::string is undefined when used as a return type but not when used as a parameter in methods of a class!

#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?!?!
};

Doing a Rebuild All it still happened I had to choose clean solution and then Rebuild All again after for the universe to realign. While it's resolved for the moment I'd still like to know what could have caused this because I'm at a loss as to why when there should be no conflicts especially when I always use fully qualified names for STL.

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-studio-2010