I keep getting this error and i am not sure how to fix it..
:24: too many arguments to function `Car GetCar (ifstream &)'
:48: at this point in file
Below is the code
--------------
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Date
{
int month;
int day;
int year;
};
struct Car
{
float price;
Date purchased;
string customer;
};
Car GetCar(ifstream &dataIn);
// Pre: File dataIn has been opened.
// Post: The fields of car are read from file dataIn.
void WriteCar(ofstream& dataOut, Car car);
// Pre: File dataOut has been opened.
// Post: The fields of car are written on file dataOut,
// appropriately labeled.
int main ()
{
Car car;
ifstream dataIn;
ofstream dataOut;
so i did make that correct and ran the program but nothing happens. Is that what is supposed to happen? Cause the question is, what is written on file Cars.out.
There is a lack of symmetry between the functions which write to and read from the file.
The Write function WriteCar() outputs data like this:
Customer: Fred
Price: 2000
Purchased:25/11/2016
Customer: Suzie Soo
Price: 3000
Purchased:28/2/2015
But the read function GetCar() expects data in a format like this:
Fred
2000
25 11 2016
Suzie_Soo
3000
28 2 2015
If you want them to work together nicely, you'll need to decide on a specific data format and use it for both read and write. And modify one or both functions accordingly.