So, I thought I was trying to do something simple, but apparently not ...
I wrote this function in order to expand it later and have a quick way to provide the user with a menu when needed by going 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; }
But for some reason I get:
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();
when I try to compile. Can anyone translate this error for me and explain that -> , thanks.
c ++ arrays
Jamie twells
source share