我试图转发声明 std::string 但它似乎不起作用。
这是我的代码:
namespace std
{
template<typename>
class allocator;
template<class _CharT>
struct char_traits;
template <typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT>>
class basic_string;
typedef basic_string<char> string;
}
包含字符串会导致此错误:reference to ‘basic_string’ is ambiguous
。有什么方法可以无错误地转发 decleare 字符串吗?
最佳答案
Is there any way forward declare std::string without errors?
没有。
关于C++ 字符串前向声明不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49581536/