I need help passing some variables between functions. I know I am doing it wrong, I just do not know how to fix it.

Here is the first part of the code which does work.



#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

struct CarType {
string maker;
int year;
float price;
};

void getYourCar( CarType & car );

int main( )
{
CarType myCar, yourCar;

myCar.maker = "Mercedes"; // I wish
myCar.year = 2005;
myCar.price = 45567.75;

getYourCar( yourCar );

cout << "Your car is a: " << yourCar.maker << endl;
cout << fixed << showpoint << setprecision( 2 ) <<
"I'll offer $" << yourCar.price - 100 << " for your car." << endl;

return 0;
}

void getYourCar( CarType & car )
{
cout << "Enter your maker: ";
cin >> car.maker;
cout << "Enter the year: ";
cin >> car.year;
cout << "Enter the price: $";
cin >> car.price;
}

now the book says to take the following program and add a member
function to the CarType class which prints the values of all of its data
members. Add two more data members which are relevant for cars. Add the use of
these data members to the program (to the assignment statements for MyCar, to
the operator prompt and input inside the getYourCar function, and to the print
function you have created).

Here is my code. Whenever I run it, it takes my assigned variables in MyCar and prints those instead of the one which the user is inputting.

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;


using namespace std;

struct CarType {
string maker;
int year;
float price;
string color;
float mileage;
void (*func)(string maker, int year, float price,float mileage, string color);
};

void getYourCar( CarType & car );
void carData(string maker, int year, float price,float mileage, string color);


int main( )
{
CarType myCar, yourCar;

myCar.maker = "Hyundai"; // This is my vechicle
myCar.year = 2012;
myCar.price = 45567.75;
myCar.mileage = 9000; // added information
myCar.color = "green"; // added information(my favorite color is green)
//myCar.func = carData;
getYourCar( yourCar );

myCar.func(myCar.maker, myCar.year, myCar.price, myCar.mileage, myCar.color);

system("PAUSE");
return 0;
}

void getYourCar( CarType & car )
{
cout << "Enter your maker for example Chevy or Ford: ";
cin >> car.maker;
cout << "Enter the year: ";
cin >> car.year;
cout << "Enter the price: $";
cin >> car.price;
cout << "Enter the mileage on the vehicle";
cin >> car.mileage;
cout << "Enter the color of the vehicle";
cin >> car.color;
}
void carData(string maker, int year, float price,float mileage, string color)
{
cout << "Your car is a: " << maker << endl;
cout << "Your vehicle has " << mileage << "on it" <<endl;
cout << "And the color is " << color << "wow" <<endl;
cout << fixed << showpoint << setprecision( 2 ) <<

"I'll offer $" << price - 100 << " for your car." << endl;
}


If anyone can point out what I am doing wrong, and explain why it is that way it would mean so much. I am not asking anyone to write my code. I am just trying to learn.

Thank you