case 2: {
string name;
cout << "Enter name to remove: ";
getline(cin, name);
int x = removeName(p1, name);
if (x == -1)
cout << "Name is not in the list" << endl;
else
count = x;
}
break;
case 3: displayName(p1);
break;
case 4:{
string name;
cout << "Enter name to find: ";
getline(cin, name);
int num = findName(p1, name);
if (num == -1){
cout << "Name not found in the list" << endl << endl;
}
else {
cout << "Name found at number " << num << " in the list." << endl << endl;
}
}
break;
case 5: sortName(p1);
break;
case 6: getLastNames(p1);
cout<<"Names Are Displayed in .txt file";
break;
115:21: warning: multi-character character constant [-Wmultichar] In function 'std::string getLastNames(Person*)':
115:28: warning: overflow in implicit constant conversion [-Woverflow]
115:41: error: no match for 'operator*' (operand type is 'std::string {aka std::basic_string<char>}')
120:1: warning: no return statement in function returning non-void [-Wreturn-type]
VS 2015
Error (active) no instance of overloaded function "getline" matches the argument list
main.cpp 35 argument types are: (std::istream, <error-type>)
Error (active) "count" is ambiguous main.cpp 35
Error (active) "count" is ambiguous main.cpp 37
Error (active) "count" is ambiguous main.cpp 38
Error (active) "count" is ambiguous main.cpp 43
Error (active) "count" is ambiguous main.cpp 58
Error (active) "count" is ambiguous main.cpp 63
Error (active) "count" is ambiguous main.cpp 63
Error (active) "count" is ambiguous main.cpp 64
Error (active) "count" is ambiguous main.cpp 69
Error (active) "count" is ambiguous main.cpp 76
Error (active) "count" is ambiguous main.cpp 83
Error (active) "count" is ambiguous main.cpp 84
Error (active) "count" is ambiguous main.cpp 94
Error (active) "count" is ambiguous main.cpp 109
Error (active) no operator "*" matches these operands main.cpp 115
Error C2872 'count': ambiguous symbol main.cpp 35
Error C2872 'count': ambiguous symbol main.cpp 37
Error C2872 'count': ambiguous symbol main.cpp 38
Error C2872 'count': ambiguous symbol main.cpp 43
Error C2872 'count': ambiguous symbol main.cpp 58
Error C2872 'count': ambiguous symbol main.cpp 63
Error C2872 'count': ambiguous symbol main.cpp 64
Error C2872 'count': ambiguous symbol main.cpp 69
Error C2872 'count': ambiguous symbol main.cpp 76
Error C2872 'count': ambiguous symbol main.cpp 83
Error C2872 'count': ambiguous symbol main.cpp 84
Error C2872 'count': ambiguous symbol main.cpp 94
Error C2872 'count': ambiguous symbol main.cpp 109
Warning C4305 'argument': truncation from 'int' to 'char' main.cpp 115
Warning C4309 'argument': truncation of constant value main.cpp 115
Error C2100 illegal indirection main.cpp 116
This is a start to how you need to rethink your data management and construction. If you use a vecor instead of an array you'll find it a little simple.
As Thomas1965 has shown you there are many errors in your program. When I loaded your program in my VS 2015 the first compile gave 57 errors.
I found the "count" being ambiguous error came from the line "using namespace std;". Along the way one of the header files includes the "utility" header file which has a "count" function in the "std" namespace,so the compiler does which version of "count" to use. After I removed the line "using namespace std;" and qualified things like "cout", "cin", "endl" and some others in the "std" namespace with "std::" snd most of the errors disappeared.
In main you have the line struct Person *p1;, but you never give p1 a value i.e., an address to use. If you want to use a pointer, I believe what you will need is:
1 2
struct Person p;
struct Person *p1 = &p;
or you could just use the "p" variable instead of the pointer.
I still want to do some work to see what I can come up with. For now this is what I have found.
In all your functions except "getName" you are using subscripts on p1, but p1 is not an array. You have not defined any kind of array in your program. I would suggest using a vector to store each "p1" struct.
The easiest parts to work on would be case 1 and case 3. Once you get these parts working the rest will be easier to fix.
For what it is worth I am having trouble with "include <cmath>" not being found, but this comes from other "include"s that are not part of what is in the main file, but are included because of what is in main.