C++ 编译出现的错误

第一种

cannot pass objects of non-trivially-copyable type ‘std::string {aka class std::basic_string<char>}
  • 1、能看到出现的问题在于 string;
  • 2、然后发现是在日志打印位置。
    原因是:参数类型是char,而传入的类型为string导致类型不匹配。通过 c_str() 将string转化为char

c_str()用法参见百科。
https://baike.baidu.com/item/c_str/2622670?fr=aladdin

posted @ 2021-02-09 17:24  小海哥哥de  阅读(517)  评论(0编辑  收藏  举报