在ubuntu编译yaml-cpp,已经生成好测是文件了,但是一运行就报错为什么
terminate called after throwing an instance of 'YAML::TypedBadConversion<std::__cxx11::basic_strinhttps://img-mid.csdnimg.cn/release/static/image/mid/ask/588163419946158.png "#left")
g<char, std::char_traits<char>, std::allocator<char> > >'
what(): bad conversion
Aborted (core dumped)
但是感觉main.cpp主函数没写错呀,有人知道为什么吗
#include<iostream>
#include <yaml-cpp/yaml.h>
using namespace std;
int main(int argc,char** argv)
{
YAML::Node config = YAML::LoadFile("../config.yaml");
cout << "name:" << config["name"].as<string>() << endl;
cout << "sex:" << config["sex"].as<string>() << endl;
cout << "age:" << config["age"].as<int>() << endl;
return 0;
}
12