Classes with Structs

So I have a problem that I have to work on which I'm having issue finding info on the internet or I'm just not putting in the right key words.

Anyways I did a program that read from a binary file and now I have to do part 2 of the assignment and I'm kind of lost of where to start.

Assignment:
Create a class that “wraps” or “hides” the information from flightRec. So your class will convert each char array from the flightRec struct into strings, and also have methods to access each data member. You can name your class whatever you want, although you should keep Meyer's general guidelines in mind (no verb names, please). In this document, I am calling the class an OverFlight.

My Current Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include <stdlib.h>
#include <iostream>
#include <cstdio>
#include <fstream>
#include <vector>
#include <iomanip>

using namespace std;

struct FlightRec {
	char flightNum[7];
	char originAirportCode[5];
	char destAirportCode[5];
	int dateStamp;
};

int main()
{
	fstream myfile;
	struct FlightRec flights;

	myfile.open("C:\\Users\\ChristopherJ\\Desktop\\Chris School\\C++\\acars.bin", ios::in | ios::binary);


	if (!myfile.is_open())	{
		cerr << "error";
		return -1;
	}
	
	while (!myfile.eof())	{
		myfile.read((char*)(&flights), sizeof(flights));
		cout << left << setw(7) << flights.flightNum << left << setw(5) << flights.originAirportCode << left << setw(5) << flights.destAirportCode << left << setw(12) <<
			flights.dateStamp << endl;
	}
	 
	myfile.close();

	return 0;
}
Topic archived. No new replies allowed.