hi,
i was wondering if anyone could help me out with this. i'm getting a compile error like this:
[C++ Error] TestDriver.cpp(26): E2285 Could not find a match for 'Airport::Airport(char *,double,char *,FlightsTL)'
i'm really sorry about this but the code is a bit lengthy. it comprises of two header files and three CPP files (two files that correspond to the header files and one TestDriver). I have to post all of the code so that you can get an understanding of what's happening. basically i'm trying to make the airport have a flight schedule by using the FlightsTL classes objects
#ifndef FLIGHTS_
#define FLIGHTS_
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <iterator>
using namespace std;
class Flight { //a class which makes a flight
private:
string org; //origin of flight
string dest; //destination of flight
double depTime; // departure time
double dura; // duration of flight
public:
//Start House-keeping functions
/*Default constructor
*
*/
Flight ();
/* Constructor for flight object
*
*
*/
Flight(const string&, const string&,const double&,const double&);
/* copy constructor for flight object
*
*
*/
// Flight(const Flight& rhs);
/**destructor for flight object
*
*
*/
~Flight();
//end House-keeping functions\\
//_________________Start of other Flight functions___________________________\\
/* Equals operation
*
*/
Flight& operator=(const Flight& rhs);
/* get origin
*
*/
string getOrigin()const;
/* get destination
*
*/
string getDestination()const;
/* get departure time
*
*/
double getDepartureTime()const;
/* get duration
*
*/
double getDuration ()const;
/* set origin
*
*/
void setOrigin(string);
/* set destination
*
*/
void setDestination(string);
/* set departure time
*
*/
void setDepartureTime(double);
/* get duration
*
*/
void setDuration(double);
/* set all
*
*/
void setAll(string,string,double,double);
/** ToString to display flight information
*
*/
string toString()const;
} ;
// _________end of Flight class__________________\\
class FlightsTL{ //container that will hold Flight objects
friend class Flight;
private:
int FlightsNum; // keeps track of how many airports there are
vector<Flight> Flights; // container for all flights
public:
/*Default constructor
*
*/
FlightsTL();
/* constructor
*
*
*/
FlightsTL(int);
/*copy constructor
*
*
*/
FlightsTL (const FlightsTL& rhs);
/*destructor
*
*
*/
~FlightsTL();
/*Equals operator
*
*
*/
FlightsTL& operator=(const FlightsTL& rhs);
/* get FlightsNum
*
*/
int getFlightsNum ();
/*is empty function
*
*/
bool isEmpty();
/* set FlightsNum
*
*/
void setFlightsNum(int);
/*add a existing Flighr
*
*/
void addFlight(const Flight&);
/*
* this is adding a new flight
*/
void addNewFlight(const string&, const string&,const double&, const double&);
/** ToString to display flight information
*
*/
string toString();
} ;
# endif /*FLIGHTS_*/
next is the corresponding CPP file
#include"Flights.h"
//_____________Start Implementation of Flight class________________\\
/*Start House-keeping functions for Flight Class
* Default constructor
*
*/
Flight:: Flight (){
//debug statement
cout<< "we are in the construtor with Default arguments\n";
setOrigin("");
setDestination("");
setDepartureTime(0);
setDuration(0) ;
}
/* Constructor for flight object
*
*
*/
Flight::Flight(const string &orig ,const string &destin ,const double &dep, const double &dur ){
//debug statement
cout<< "we are in the construtor with arguments\n";
setOrigin(orig);
setDestination(destin);
setDepartureTime(dep);
setDuration(dur);
}
/* copy constructor for flight object
*
*
*
FlightsTL:: Flight:: Flight(const Flight& rhs){
} */
/**destructor for flight object
*
*
*/
Flight:: ~Flight(){
}
//end House-keeping functions \\
//_____________Start other functions____________________________\\
/* Equals operation
*
*/
Flight& Flight::operator=(const Flight& rhs){
return *this;
}
/* get origin
*
*/
string Flight::getOrigin() const{
return org;
}
/* get destination
*
*/
string Flight::getDestination()const{
return dest;
}
/* get departure time
*
*/
double Flight:: getDepartureTime()const{
return depTime;
}
/* get duration
*
*/
double Flight:: getDuration ()const{
return dura;
}
/* set origin
*
*/
void Flight:: setOrigin(string t ){
org = t;
}
/* set destination
*
*/
void Flight:: setDestination(string s){
dest =s;
}
/* set departure time
*
*/
void Flight:: setDepartureTime(double c){
depTime = c;
}
/* get duration
*
*/
void Flight:: setDuration(double d){
dura = d;
}
/* set all
*
*/
void Flight:: setAll(string a,string b,double c,double d){
setOrigin(a);
setDestination(b);
setDepartureTime(c);
setDuration(d) ;
}
/** ToString to display flight information
*
*/
string Flight:: toString()const{
string s;
double depT = getDepartureTime();
double durA = getDuration();
// convert double to string
char deptStr[50];
sprintf(deptStr,"%g",depT);
// convert to string
char durStr[50];
sprintf(durStr,"%g",durA);
// print all Flight information
s=getOrigin() +"\t"+ getDestination() + "\t"+ deptStr + "\t"+ durStr +"\n" ;
return s;
}
//__________________end of Flight implementation_____________\\
//__________________Start of of FlightsTL implementation_____________\\
/*Default constructor
*
*/
FlightsTL::FlightsTL(){
FlightsNum = 0;
}
/* constructor
*
*
*/
// FlightsTL:: FlightsTL(int num){
// }
/*copy constructor
*
*
*/
FlightsTL:: FlightsTL (const FlightsTL& rhs){
Flights = rhs.Flights;
}
/*destructor
*
*
*/
FlightsTL:: ~FlightsTL(){
}
/*Equals operator
*
*
*/
FlightsTL& FlightsTL::operator=(const FlightsTL& rhs){
if (this != &rhs){
return *this;
}
return *this;
}
/* get FlightsNum
*
*/
int FlightsTL:: getFlightsNum (){
return FlightsNum;
}
/* is empty method
*
*/
bool FlightsTL:: isEmpty(){
if(FlightsNum == 0){
return true;
}
return false;
}
/* set FlightsNum
*
*/
void FlightsTL:: setFlightsNum(int num){
FlightsNum = num;
}
void FlightsTL::addFlight(const Flight& Flight){
Flights.push_back(Flight);
FlightsNum++;
}
/*add Flighr
*
*/
void FlightsTL:: addNewFlight(const string& origin , const string& destination,const double& depTime, const double& duration){
Flights.push_back(Flight(origin,destination,depTime,duration));
FlightsNum++;
}
/** ToString to display all flights and thier information
*
*/
string FlightsTL:: toString(){
vector<Flight>::iterator find;
string str;
if (getFlightsNum() == 0) {
return "Nothing to show" ;
}
for(find = Flights.begin(); find != Flights.end(); find++){
str+=(*find).toString();
}
return str;
}
//__________________end of FlightsTL Implementation______________\\
//think about adding remove(), and clear() and add via text
here's the next header file
#ifndef AIRPORTS_
#define AIRPORTS_
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <iterator>
#include"Flights.h"
using namespace std;
class Airport { //a class which makes an Airport
private:
string code; // three letter code for airport
double minConnect; //minimum connection time between Flights
string description; //a description of airport
FlightsTL scheduel;
public:
//Start House-keeping functions
/*Default constructor
*
*/
Airport ();
/* Constructor for Airport object
*
*
*/
Airport(const string&, const double&, const string&,const Flight& );
/* copy constructor for Airport object
*
*
*/
// Airport(const Airport& rhs);
/**destructor for Airport object
*
*
*/
~Airport();
//end House-keeping functions\\
//_________________Start of other Airport functions___________________________\\
/* Equals operation
*
*/
Airport& operator=(const Airport& rhs);
/* get minimum connection
*
*/
double getMinimumConnectionTime()const;
/* get Code
*
*/
string getCode()const;
/* get description
*
*/
string getDescription()const;
/*
* get scheduel
*
*/
FlightsTL getScheduel();
/*
* set scheduel
*
*/
void setScheduel(const FlightsTL&);
/* set minimum connection time
*
*/
void setMinimumConnect (double);
/* set code
*
*/
void setCode (string);
/* set description
*
*/
void setDescription (string);
/* set all
*
*/
void setAll (string,double,string);
/** ToString to display Airport information
*
*/
string toString()const;
} ;
// _________end of Airport class__________________\\
class AirportsTL{ //container that will hold Airport objects
friend class Airport;
private:
int AirportsNum; // keeps track of how many airports there are
vector<Airport> Airports; // container for all Airports
public:
/*Default constructor
*
*/
AirportsTL();
/* constructor with arguments
*
*
*/
AirportsTL(int);
/*copy constructor
*
*
*/
AirportsTL (const AirportsTL& rhs);
/*destructor
*
*
*/
~AirportsTL();
/*Equals operator
*
*
*/
AirportsTL& operator=(const AirportsTL& rhs);
/* get AirportsNum
*
*/
int getAirportsNum ();
/*is empty function
*
*/
bool isEmpty();
/* set AirportsNum
*
*/
void setAirportsNum (int);
/*add a existing Flighr
*
*/
void addAirport(const Airport&);
/*
* this is adding a new Airport
*/
void addNewAirport(const string&,const double&, const string&);
/** ToString to display Airport information
*
*/
string toString();
} ;
#endif /*AIRPORTS_*/
here's the corresp CPP file
#include "Airports.h"
//_____________________Start of Airport Class Implementation_________________\\
//Start House-keeping functions
/*Default constructor
*
*/
Airport:: Airport (){
setCode("");
setMinimumConnect(0);
setDescription("");
setScheduel(FlightsTL plan);
}
/* Constructor for Airport object
*
*
*/
Airport:: Airport(const string& code, const double& minCon, const string& description,const Flight& Fplan){
setCode(code);
setMinimumConnect(minCon);
setDescription(description);
setScheduel(Fplan);
}
/* copy constructor for Airport object
*
*
*/
// Airport(const Airport& rhs);
/**destructor for Airport object
*
*
*/
Airport:: ~Airport(){
}
//end House-keeping functions\\
//_________________Start of other Airport functions___________________________\\
/* Equals operation
*
*/
Airport& Airport:: operator=(const Airport& rhs){
return *this;
}
/* get minimum connection
*
*/
double Airport:: getMinimumConnectionTime()const{
return minConnect;
}
/* get Code
*
*/
string Airport:: getCode()const{
return code;
}
/* get description
*
*/
string Airport:: getDescription()const{
return description;
}
/*
* get scheduel
*
*/
FlightsTL Airport:: getScheduel(){
return scheduel;
}
/*
* set scheduel
*
*/
void Airport::setScheduel(const FlightsTL& s){
scheduel =s;
}
/* set minimum connection time
*
*/
void Airport:: setMinimumConnect (double a){
minConnect =a;
}
/* set code
*
*/
void Airport:: setCode (string b){
code = b;
}
/* set description
*
*/
void Airport:: setDescription (string c){
description = c;
}
/* set all
*
*/
void Airport:: setAll (string a,double b,string c){
setMinimumConnect(b) ;
setCode(a);
setDescription(c);
}
/** ToString to display Airport information
*
*/
string Airport:: toString()const{
string s;
double mCon = getMinimumConnectionTime();
// convert double to string
char mConStr[50];
sprintf(mConStr,"%g",mCon);
// print all Airport information
s=getCode() +"\t"+ mConStr + "\t"+ "\t"+ getDescription() +"\n" ;
return s;
}
//____________________end of Airport class implementation___________________\\
//____________________Start of AirportsTL class implementation_______________\\
/*Default constructor
*
*/
AirportsTL:: AirportsTL(){
AirportsNum = 0;
}
/* constructor with arguments
*
*
*/
//AirportsTL:: AirportsTL(int){
//}
/*copy constructor
*
*
*/
AirportsTL:: AirportsTL (const AirportsTL& rhs){
Airports =rhs.Airports;
}
/*destructor
*
*
*/
AirportsTL:: ~AirportsTL(){
}
/*Equals operator
*
*
*/
AirportsTL& AirportsTL:: operator=(const AirportsTL& rhs){
if (this != &rhs){
return *this;
}
return *this;
}
/* get AirportsNum
*
*/
//------------end of house-keeping------------------\\
int AirportsTL::getAirportsNum (){
return AirportsNum;
}
/*is empty function
*
*/
bool AirportsTL:: isEmpty(){
if(AirportsNum == 0){
return true;
}
return false;
}
/* set AirportsNum
*
*/
void AirportsTL:: setAirportsNum (int a){
AirportsNum = a;
}
/*add a existing Flighr
*
*/
void AirportsTL:: addAirport(const Airport& Airport){
Airports.push_back(Airport);
AirportsNum++;
}
/*
* this is adding a new Airport
*/
void AirportsTL:: addNewAirport(const string& code,const double& minCon, const string& desc){
Airports.push_back(Airport(code,minCon,desc));
AirportsNum++;
}
/** ToString to display Airport information
*
*/
string AirportsTL:: toString(){
vector<Airport>::iterator find;
string str;
if (getAirportsNum() == 0) {
return "Nothing to show" ;
}
for(find = Airports.begin(); find != Airports.end(); find++){
str+=(*find).toString();
}
return str;
}
//____________________end of AirportsTL implementation______________________\\
// remember to ad extra functions remove(), clear() etc
and here's the TestDriver
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include<iostream>
#include"Flights.h"
#include "Airports.h"
using namespace std;
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[]){
//Create a Flight object using argumets
Flight b ("adl","mel",1.00,1.30);
//Create a Flight object using no argumets
Flight d;
//Create FlightsTL object
FlightsTL C;
//Attempt to put Flight object into FlightsTL
//there is an error when this line is uncommented
C.addNewFlight("syd","per",1.00,1.30);
C.addFlight(b);
//Constructor for airport trying to make it accept a set of flights at the end
Airport a("syd",0.30,"Sydney domestic airport",C);
//Airport z("Mel",2.30,"Melbourne domestic airport");
AirportsTL j;
j.addAirport(a);
//j.addAirport(z);
//cout<< "TESTING "<< j.toString()<<"\n";
//cout<< "TESTING "<< d.toString()<<"\n";
system("pause");
return 0;
}
//---------------------------------------------------------------------------
thanks for the help in advance
Jay F