T
Tommy
Hello everyone,
any idea how to read data from file into structure?
I have problem only with enum type.
Lets say I have enum type defined like this:
enum transport
{
bus,
plane
} ;
I have also structure
struct data
{
int number ;
transport tr ;
}
and I also have a binary file called data.dat which
looks more less like this:
1 bus
2 plane
And in main() i have
{
ifstream in("data.dat", ios::binary) ;
data buffer ;
// read number
in >> buffer.number ; // ok works well
// problem starts with enum
in >> buffer.tr ; // any idea how to read this?
}
Do I have to overload operator>> ?
Best regards
tommy
any idea how to read data from file into structure?
I have problem only with enum type.
Lets say I have enum type defined like this:
enum transport
{
bus,
plane
} ;
I have also structure
struct data
{
int number ;
transport tr ;
}
and I also have a binary file called data.dat which
looks more less like this:
1 bus
2 plane
And in main() i have
{
ifstream in("data.dat", ios::binary) ;
data buffer ;
// read number
in >> buffer.number ; // ok works well
// problem starts with enum
in >> buffer.tr ; // any idea how to read this?
}
Do I have to overload operator>> ?
Best regards
tommy