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
1
Expert's answer
2013-04-17T08:45:24-0400
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; } }
Comments
Leave a comment