<分区>
我有一个由字符串和整数组成的对 vector ,例如:{("ABC", 15), ("DEFG", 29)}。我想将字符串拆分为 vector 中的单独字符,因此 {'A', 'B', 'C'}。我的代码是:
for (std::pair<std::string, int> i: code)
{
std::vector <char> letters;
for (char b: i.first())
'代码'是原始 vector 。这段代码给我错误:
error: type 'std::__1::basic_string<char>' does not provide a call operator
for (char b: i.first())
^~~~~~~
我不明白这个,有没有办法解决这个问题?