小编dri*_*733的帖子

'std :: string'没有名为'front'的成员

#include <string>
#include <algorithm>
#include <iostream>

int main()
{
    string str;
    string str1;
    int h = 0;
    cin >> str;
    if (str.length() > 10)
    {
        str1 += str.front();
        h = str.length() - 2;
        string s = to_string(h);
        str1 += s;
        str1 += str.back();
        cout << str1;
    }
    else cout << str;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译在XCode中,但不在codeforces.ru/上

 ?an't compile program.cpp:
program.cpp: In function 'int main()':
program.cpp:23:21: error: 'std::string' has no member named 'front'
program.cpp:27:29: error: 'to_string' was not declared in this scope …
Run Code Online (Sandbox Code Playgroud)

c++ string

6
推荐指数
2
解决办法
1万
查看次数

swift 2.0中的拆分方法(XCode 7 beta 5)

我刚刚将Xcode 7更新为beta5,并发现split函数已被split方法替换.我对Swift没有经验,但还没弄明白如何将我当前的代码更新为新语法.

let components = split(name.characters){$0 == "."}.map { String($0) }
// 'split(_:maxSplit:allowEmptySlices:isSeparator:)' is unavailable: Use the split() method instead.
Run Code Online (Sandbox Code Playgroud)

ios swift swift2 xcode7-beta5

1
推荐指数
1
解决办法
1368
查看次数

标签 统计

c++ ×1

ios ×1

string ×1

swift ×1

swift2 ×1

xcode7-beta5 ×1