I need some help writing a class that allows me to store an array into a class that uses Vectors as the underlying structure. I am having trouble in storing the array into the private member vector.
Can anyone help me figure this out?
I know i need to create a constructor that has can store the information from another class into this vector. But in main I create the array.
//contructor -> actually a normal member function
void setnames(string f, string l)
{
cout << "type names: ";
getline(cin,f);
getline(cin,l);
first = f;
last = l;
getline(cin,first);
getline(cin,last);
}
1 2 3 4 5 6 7 8 9
// contact list has no member first or list
ContactList::ContactList()
{
first = "Empty";
list = "Empty";
}
// cant convert array to reference
work.setVecNames(name);
I'm not sure how this compiled.
1 2 3 4 5
void setVecNames(Contact array[MAX])
{
// loop through array
// use push_back to assign elements
}