Implement a class Person with two fields name and age, and a class Car with three fields:
(1). the model, (2). a pointer to the owner (aPerson*), (3). a pointer to the driver (also a Person)

Write a program that prompts the user to specify people and cars. Store them in a vector<Person*> and a vector<Car*>. Traverse the vector of Person objects and increment their ages by one year. Finally, traverse the vector of cars and print out the car model, owner’s name and age, and driver’s name and age.

this is the problem that i want to solve anyone can tell me how to start bcoz tomorrow i have to submit this i am waiting plz tell me

There are no freebies here. We can help you if you show that you have done some efforts of your own and if you are stuck on some specific problem(s). Don't expect to just ask and get people to solve your homework assignments. That wouldn't be helpful to you, nor would it be righteous.

that is the program that i have to extend and take the input from user to populate the vector which contains the name and age of a person and the model from the class car
and class car takes the name and age of the driver from the class person. now plz help me

#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Person
{
private:
string name;
int age;
public:
Person(string n, int a);
string get_name()const;
int get_age()const;
void Person::increment_age();
void print()const;
};

Person::Person(string n, int a){ 
name = n;
age = a;}

string Person::get_name() const{
return name;}

void Person::increment_age(){
age += 1;}

void Person::print() const{
cout << name << endl;
cout << age << endl;}


class Car
{
private:
string model;
Person *owner;
Person *driver;
public:
Car::Car(string m);
void Car::set_driver(Person* p);
void Car::set_owner(Person* p);
void print()const;
}; 


Car::Car(string m){
model = m;}

void Car::set_driver(Person* p){
*driver = *p;}

void Car::set_owner(Person* p){
*owner = *p;}

void Car::print() const{
cout << model << endl;
cout << &driver << endl;
cout << &owner << endl;}




int main()
{ 

vector<Person*> people;

const int PERSON_SZ = 4;
char * names[] = {"Jim", "Fred", "Harry", "Linda"};
int ages[] = { 23, 35, 52, 59 };

for (int i = 0; i < PERSON_SZ; i++){
Person *a = new Person(names[i], ages[i]);
people.push_back(a);}




vector<Car*> cars;

const int CAR_SZ = 3;
char * models[] = { "Festiva", "Ferrarri", "Prius" };

for (int i = 0; i < CAR_SZ; i++)
{
Car *c = new Car(models[i]);
c->set_driver(people[rand()% (people.size())]);
c->set_owner(people[rand()% (people.size())]);
cars.push_back(c);
}
return 0;
}

It seems like you are pretty much done, you just have to fix lines 60 and 61 to:

cout << "Driver: "; driver->print();
cout << "Owner: "; owner->print();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.