i'm a begginer in c++ and I need to make some automobile related classes that need to be read from a file.In one of them I want to use an enum my class looks like this:
enum engines{ gasoline, hybrid, diesel };
class Automobil
{
const int id;
char *model;
engines engine;
int max_speed;
int engine_cc;
float avg_consumption_urban;
float avg_consumption;
float avg_speed_urban;
float avg_speed;
}
and i need to overload the >> operator to read the object from a file but when I do it for the engine,I have errors. How do I still keep the enum and read from the file?
friend ifstream& operator>>(ifstream& input, Automobil &a)
{
delete[] a.model;
input >> a.model;
input >>a.engine; //error here
input >> a.max_speed;
input >> a.engine_cc;
input >> a.avg_consumption_urban;
input >> a.avg_speed_urban;
input >> a.avg_consumption;
input >> a.avg_speed;
return input;
}