【发布时间】:2020-07-02 07:48:59
【问题描述】:
尝试运行:
// appending to string
#include <iostream>
#include <string>
int
main()
{
std::string str;
std::string str2 = "Writing ";
std::string str3 = "print 10 and then 5 more";
// used in the same order as described above:
str.append(str2); // "Writing "
str.append(str3, 6, 3); // "10 "
str.append("dots are cool", 5); // "dots "
str.append("here: "); // "here: "
str.append(10u, '.'); // ".........."
str.append(str3.begin() + 8, str3.end()); // " and then 5 more"
str.append<int>(5, 0x2E); // "....."
std::cout << str << '\n';
return 0;
}
但是在 str.append(5,0x2E) 上有错误:
错误:没有匹配函数调用'std::__cxx11::basic_string::append(int, int)'
使用 VS Code 1.43.1,在 ubuntu 19.10 上运行,gcc 版本 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)。
我尝试在 Code::Blocks 16.01 IDE 和 windows 上运行代码,但出现了同样的错误。
【问题讨论】:
标签: c++ compiler-errors int append