Hi all,
Thank you in advance for any help you can offer.
If I have a class named employees, and each employee has a:
string first_name, last_name;
int age;
then I make a vector of employees objects:
vector <employees> workers(10)
What is the syntax for displaying the 3rd workers objects last_name?
//This didn't work for me:
cout << workers[3].last_name << endl;
// I tried an iterator like this, but it didn't work either:
vector <employees> ::iterator ptr;
for(ptr = workers.begin(); ptr != workers.end(); ptr++)
{
cout << ptr.last_name << endl;
}
/end
Best regards,
Dane
|