0

我找到了这个例子:

ofstream ofstr("output.yaml");
YAML::Emitter out(ofstr);
out << some_large_document;

// not necessary anymore:
// ofstr << out.c_str()

但是当我尝试使用它时,我有:

D:\work\C\map.cpp||In function `int main()':|
D:\work\C\map.cpp|24|error: no matching function for call to `YAML::Emitter::Emitter(std::ofstream&)'|
D:\work\C\yaml-cpp\emitter.h|23|note: candidates are: YAML::Emitter::Emitter(YAML::Emitter&)|
D:\work\C\yaml-cpp\emitter.h|25|note:                 YAML::Emitter::Emitter()|
||=== Build finished: 1 errors, 0 warnings ===|
4

1 回答 1

2

没有构造函数YAML::Emitter接受流。(你在哪里找到那个例子?)

相反,您确实需要使用注释掉的行:

ofstream ofstr("output.yaml");
YAML::Emitter out;
out << some_large_document;
ofstr << out.c_str(); // is necessary!
于 2011-06-11T20:14:13.293 回答