I've been at this code for the past few hours and cant seem to wrap my head around what the error could be. I've created the member functions and I'm sure they're being called correctly in main. Before every variable being used as an argument for the class functions being called in main, the error message is "Error: expected primary expression before 'variable'".
class Name_pairs
{
public:
Name_pairs();
void read_names(string nameOfPerson, vector <string> names);
void read_ages(vector <double> ages, double ageOfPerson, vector <string>& names);
void print();
private:
string nameOfPerson;
double ageOfPerson;
vector <string> names;
vector <double> ages;
};`
Name_pairs::Name_pairs()
{
}
Name_pairs::read_names(nameOfPerson, names)
{
while(true)
{
cout << "Please enter a name: (enter q to end) " << endl;
cin >> nameOfPerson;
if(nameOfPerson == q)
{
names.push_back(nameOfPerson);
break;
}else{
names.push_back(nameOfPerson);
}
}
}
Name_pairs::read_ages(ages,ageOfPerson, names)
{
int z =0;
while(true)
{
cout << "Please enter " << names[a] << "'s age: "
cin >> ageOfPerson;
ages.push_back(ageOfPerson);
z++;
if(ages.size()== names.size() )
{
break;
}
}
}
And then where the problem occurs is in the main function.
int main()
{
Name_pairs identifier;
identifier.read_names(string nameOfPerson, vector <string> names);
identifier.read_ages(vector <double> ages, double ageOfPerson, vector <string> names);
return 0;
}
Any help will be appreciated