I created a vector out of a struct to store multiple types of values. However, I can't get input to work.
#include "std_lib_facilities.h"
struct People{
string name;
int age;
};
int main()
{
vector<People>nameage;
cout << "Enter name then age until done. Press enter, 0, enter to continue.:\n";
People name;
People age;
while(name != "0"){
cin >> name;
nameage.push_back(name);
cin >> age;
nameage.push_back(age);}
vector<People>::iterator i = (nameage.end()-1);
nameage.erase(i);
}
I've also tried having the name and age variables in the main function be string/int types, and while that fixes the operator issue, it leads to an issue with function calling in the push_back line.
P.S. Is it possible to push_back multiple inputs such as...
cin >> name >> age;
nameage.push_back(name,age);
?