所以,我以为我是想做一些简单的事,但显然不是......
我写了这个函数,所以我可以稍后扩展它,并有一个快速的方法,在需要时给用户一个菜单menu(mystrings):
int menu(string a[]) {
    int choice(0);
    cout << "Make a selection" << endl;
    for(int i=0; i<a.size(); i++) {
        cout << i << ") " << a[i] << endl;
    }
    cin >> choice;
    cout << endl;
    return choice;
}
但出于某种原因,我得到:
main.cpp: In function ‘int menu(std::string*)’:
main.cpp:38:12: error: request for member ‘size’ in ‘a’, which is of pointer type ‘std::string* {aka std::basic_string<char>*}’ (maybe you meant to use ‘->’ ?)
  int n = a.size();
当我尝试编译时.可以有人为我翻译这个错误并解释是什么->,谢谢.
yiz*_*lez 14
您正在传递一个数组strings并尝试调用size()该数组.传递给函数时,数组退化为指针,这解释了您的错误.
该->经营者,或"箭经营者"(我用的名字),只是简写(*obj).func().如果您有一个指向类对象的指针,这将非常有用.例:
string *s = &someotherstring;
s->size(); //instead of (*s).size(), saves keystrokes