Hi all,

i was hoping some on could help me solve this problem i am having:i have been going over it for the past two hours but can not find the mistake\s. I have three files i am working on 1 header and 2 cpp ones(implementation of header file and TestDriver )I am getting this error:

[Linker Error] Error: Unresolved external 'Flight::Flight(const Flight&)' referenced from I:\DOCUMENTS AND SETTINGS\JAYHIZZEY\MY DOCUMENTS\BORLAND STUDIO PROJECTS\C++ ***3 PROJECT\DEBUG_BUILD\FLIGHTS.OBJ

here is the code for the header file:

#ifndef FLIGHTS_
#define FLIGHTS_
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
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 (int);

		   /* 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()const;


			} ;
#                endif /*FLIGHTS_*/

header implementation 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 (int num){

			   return FlightsNum;

		   }

		   /* 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()const{

			return "";

		   }


	  //__________________end of FlightsTL Implementation______________\\

and the TestDriver

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include<iostream>
#include"Flights.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);


	cout<< "TESTING "<< d.toString()<<"\n";

	system("pause");
	return 0;
}
//---------------------------------------------------------------------------

if any other problems (potential or current) are found please let me know, and give me a help hand please.

Recommended Answers

All 2 Replies

You've commented out the definition of the copy constructor for Flight.

You've commented out the definition of the copy constructor for Flight.

that helped thats;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.