当我尝试编译下面的代码时(在 Qt 4.8 中使用 llvm-g++-4.2 (GCC) 4.2.1),我收到以下错误:
../GLWidget.cpp:24: instantiated from here
../GLWidget.cpp:24: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
这个错误是什么意思,我应该怎么做才能修复它?
源代码:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void testOStream(){
filebuf fb;
fb.open ("test.txt",ios::out);
std::ostream os(&fb);
std::string test("test");
os << test; // This line has the problem
fb.close();
}