67 001
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #28559 in C++ for Paul

Question #28559
I am asking for any help with this program.a class called flight that displays flight number,flight name,origin and time of arrival then adds a new flight or deletes a flight
Expert's answer
There are some approaches to solve such problems, butmost of them are using containers. Because you need to store somewhere all of
flights.

There is many containers, such as vector (very close toarray), list (linked list), map (store some value with keys to fast search
through it), queue and etc. These are most common containers. They can be found
in STL (standard template library). There is some example to store, delete and
find some flights.

class Flight {
//....some of yourvalues
intflight_number;
};

#include <vector>
using namespace std;

//........
//....in some function
vector <Flight> Flight_vector;
Flight flight_one(100); //100 - flight numberFlight_vector.push_back(&Flight); //adding to back of vector;

//deleting
int fn_to_delete = 1000; //flight number to delete
for(vector <Flight*> ::iterator i = Flights.begin();
i !=Flights.end(); ++i) { //iterator approach
if((*i).flight_number = fn_to_delete) {
flights.erase(i);
break;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions