1.编译错误error: binding ‘const Person’ to reference of type ‘Person&’ discards qualifiers|
意思是在进行函数传参时,不能把常变量(这里是常引用)传递给非常变量(Person&,这里是非常引用)
解决方法:去看一下你的函数的形参和实参,是常还是非常。常不能传给非常,但非常可以传给常。
std::string LcmReceiver::extract(const std::string &values, int index, char delim = ' ') {
if (values.length() == 0)
return std::string("");
std::vector<std::string> x = split(values, delim);
try {
return x.at(index);
} catch(const std::out_of_range& e) {
return std::string(""); // 要是访问超出范围的元素,我们就返回空串
}
}
2。设置了按照时间戳保存图片,编译也没问题,就是执行后没有保存的结果。是因为文件名不能有冒号,把冒号改成-就可以了。
std::time_t t;
std::tm* local;
char buf[128]= {0};
t = time(NULL);
local = localtime(&t); //转为本地时间
strftime(buf, 64, "%Y-%m-%d-%H-%M-%S", local);
std::string output_file = buf;
output_file=output_file+".jpg";