简体   繁体   中英

Visual Studio 2010 compile error with std::string?

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.

This is probably a compiler bug. I have seen several others in VS2010.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM