Can Anyone find the error here?

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2008
Posts: 21
Reputation: 007tron is an unknown quantity at this point 
Solved Threads: 0
007tron 007tron is offline Offline
Newbie Poster

Can Anyone find the error here?

 
0
  #1
Jun 13th, 2008
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:

  1.  
  2. #ifndef FLIGHTS_
  3. #define FLIGHTS_
  4. #include <iostream>
  5. #include <string>
  6. #include <vector>
  7. #include <sstream>
  8. using namespace std;
  9.  
  10. class Flight { //a class which makes a flight
  11.  
  12. private:
  13. string org; //origin of flight
  14. string dest; //destination of flight
  15. double depTime; // departure time
  16. double dura; // duration of flight
  17.  
  18.  
  19. public:
  20. //Start House-keeping functions
  21. /*Default constructor
  22. *
  23. */
  24. Flight ();
  25.  
  26. /* Constructor for flight object
  27. *
  28. *
  29. */
  30. Flight(const string&, const string&,const double&,const double&);
  31.  
  32. /* copy constructor for flight object
  33. *
  34. *
  35. */
  36.  
  37. Flight(const Flight& rhs);
  38.  
  39. /**destructor for flight object
  40. *
  41. *
  42. */
  43. ~Flight();
  44.  
  45. //end House-keeping functions\\
  46.  
  47. //_________________Start of other Flight functions___________________________\\
  48.  
  49. /* Equals operation
  50. *
  51. */
  52. Flight& operator=(const Flight& rhs);
  53.  
  54. /* get origin
  55. *
  56. */
  57. string getOrigin()const;
  58.  
  59. /* get destination
  60. *
  61. */
  62. string getDestination()const;
  63.  
  64. /* get departure time
  65. *
  66. */
  67. double getDepartureTime()const;
  68.  
  69. /* get duration
  70. *
  71. */
  72. double getDuration ()const;
  73.  
  74. /* set origin
  75. *
  76. */
  77. void setOrigin(string);
  78.  
  79. /* set destination
  80. *
  81. */
  82. void setDestination(string);
  83.  
  84. /* set departure time
  85. *
  86. */
  87. void setDepartureTime(double);
  88.  
  89. /* get duration
  90. *
  91. */
  92. void setDuration(double);
  93.  
  94. /* set all
  95. *
  96. */
  97.  
  98. void setAll(string,string,double,double);
  99.  
  100. /** ToString to display flight information
  101. *
  102. */
  103. string toString()const;
  104.  
  105.  
  106. } ;
  107.  
  108.  
  109.  
  110. // _________end of Flight class__________________\\
  111.  
  112.  
  113.  
  114.  
  115. class FlightsTL{ //container that will hold Flight objects
  116.  
  117.  
  118. friend class Flight;
  119.  
  120. private:
  121. int FlightsNum; // keeps track of how many airports there are
  122. vector<Flight> Flights; // container for all flights
  123.  
  124. public:
  125.  
  126.  
  127. /*Default constructor
  128. *
  129. */
  130. FlightsTL();
  131.  
  132. /* constructor
  133. *
  134. *
  135. */
  136.  
  137. FlightsTL(int);
  138.  
  139. /*copy constructor
  140. *
  141. *
  142. */
  143.  
  144. FlightsTL (const FlightsTL& rhs);
  145.  
  146. /*destructor
  147. *
  148. *
  149. */
  150. ~FlightsTL();
  151.  
  152. /*Equals operator
  153. *
  154. *
  155. */
  156. FlightsTL& operator=(const FlightsTL& rhs);
  157.  
  158. /* get FlightsNum
  159. *
  160. */
  161. int getFlightsNum (int);
  162.  
  163. /* set FlightsNum
  164. *
  165. */
  166. void setFlightsNum(int);
  167.  
  168. /*add a existing Flighr
  169. *
  170. */
  171. void addFlight(const Flight&);
  172.  
  173. /*
  174. * this is adding a new flight
  175. */
  176. void addNewFlight(const string&, const string&,const double&, const double&);
  177.  
  178. /** ToString to display flight information
  179. *
  180. */
  181. string toString()const;
  182.  
  183.  
  184. } ;
  185. # endif /*FLIGHTS_*/

header implementation cpp file

  1. #include"Flights.h"
  2.  
  3. //_____________Start Implementation of Flight class________________\\
  4.  
  5.  
  6. /*Start House-keeping functions for Flight Class
  7. * Default constructor
  8. *
  9. */
  10. Flight:: Flight (){
  11. //debug statement
  12. cout<< "we are in the construtor with Default arguments\n";
  13.  
  14. setOrigin("");
  15. setDestination("");
  16. setDepartureTime(0);
  17. setDuration(0) ;
  18.  
  19.  
  20. }
  21.  
  22. /* Constructor for flight object
  23. *
  24. *
  25. */
  26. Flight::Flight(const string &orig ,const string &destin ,const double &dep, const double &dur ){
  27. //debug statement
  28. cout<< "we are in the construtor with arguments\n";
  29.  
  30. setOrigin(orig);
  31. setDestination(destin);
  32. setDepartureTime(dep);
  33. setDuration(dur);
  34.  
  35.  
  36.  
  37. }
  38.  
  39. /* copy constructor for flight object
  40. *
  41. *
  42. *
  43.  
  44. FlightsTL:: Flight:: Flight(const Flight& rhs){
  45.  
  46.  
  47.  
  48. } */
  49.  
  50. /**destructor for flight object
  51. *
  52. *
  53. */
  54. Flight:: ~Flight(){
  55.  
  56.  
  57.  
  58.  
  59.  
  60. }
  61. //end House-keeping functions \\
  62.  
  63.  
  64. //_____________Start other functions____________________________\\
  65.  
  66. /* Equals operation
  67. *
  68. */
  69. Flight& Flight::operator=(const Flight& rhs){
  70.  
  71. return *this;
  72. }
  73.  
  74. /* get origin
  75. *
  76. */
  77. string Flight::getOrigin() const{
  78.  
  79. return org;
  80. }
  81.  
  82. /* get destination
  83. *
  84. */
  85. string Flight::getDestination()const{
  86.  
  87. return dest;
  88.  
  89. }
  90.  
  91. /* get departure time
  92. *
  93. */
  94. double Flight:: getDepartureTime()const{
  95.  
  96. return depTime;
  97.  
  98. }
  99.  
  100. /* get duration
  101. *
  102. */
  103. double Flight:: getDuration ()const{
  104.  
  105. return dura;
  106.  
  107. }
  108.  
  109. /* set origin
  110. *
  111. */
  112. void Flight:: setOrigin(string t ){
  113.  
  114. org = t;
  115. }
  116.  
  117. /* set destination
  118. *
  119. */
  120. void Flight:: setDestination(string s){
  121.  
  122. dest =s;
  123.  
  124. }
  125.  
  126. /* set departure time
  127. *
  128. */
  129. void Flight:: setDepartureTime(double c){
  130.  
  131. depTime = c;
  132. }
  133.  
  134. /* get duration
  135. *
  136. */
  137. void Flight:: setDuration(double d){
  138.  
  139. dura = d;
  140. }
  141.  
  142. /* set all
  143. *
  144. */
  145.  
  146. void Flight:: setAll(string a,string b,double c,double d){
  147.  
  148. setOrigin(a);
  149. setDestination(b);
  150. setDepartureTime(c);
  151. setDuration(d) ;
  152. }
  153.  
  154. /** ToString to display flight information
  155. *
  156. */
  157. string Flight:: toString()const{
  158. string s;
  159. double depT = getDepartureTime();
  160. double durA = getDuration();
  161. // convert double to string
  162. char deptStr[50];
  163. sprintf(deptStr,"%g",depT);
  164. // convert to string
  165. char durStr[50];
  166. sprintf(durStr,"%g",durA);
  167. // print all Flight information
  168. s=getOrigin() +"\t"+ getDestination() + "\t"+ deptStr + "\t"+ durStr +"\n" ;
  169. return s;
  170. }
  171.  
  172.  
  173. //__________________end of Flight implementation_____________\\
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180. //__________________Start of of FlightsTL implementation_____________\\
  181.  
  182. /*Default constructor
  183. *
  184. */
  185. FlightsTL::FlightsTL(){
  186.  
  187. FlightsNum = 0;
  188.  
  189. }
  190.  
  191. /* constructor
  192. *
  193. *
  194. */
  195.  
  196. // FlightsTL:: FlightsTL(int num){
  197.  
  198.  
  199.  
  200. // }
  201.  
  202. /*copy constructor
  203. *
  204. *
  205. */
  206.  
  207. FlightsTL:: FlightsTL (const FlightsTL& rhs){
  208. Flights = rhs.Flights;
  209.  
  210.  
  211. }
  212.  
  213. /*destructor
  214. *
  215. *
  216. */
  217. FlightsTL:: ~FlightsTL(){
  218.  
  219.  
  220. }
  221.  
  222. /*Equals operator
  223. *
  224. *
  225. */
  226. FlightsTL& FlightsTL::operator=(const FlightsTL& rhs){
  227. if (this != &rhs){
  228. return *this;
  229. }
  230.  
  231. return *this;
  232. }
  233.  
  234. /* get FlightsNum
  235. *
  236. */
  237. int FlightsTL:: getFlightsNum (int num){
  238.  
  239. return FlightsNum;
  240.  
  241. }
  242.  
  243. /* set FlightsNum
  244. *
  245. */
  246. void FlightsTL:: setFlightsNum(int num){
  247.  
  248. FlightsNum = num;
  249.  
  250. }
  251.  
  252. void FlightsTL::addFlight(const Flight& Flight){
  253.  
  254. Flights.push_back(Flight);
  255. FlightsNum++;
  256.  
  257. }
  258.  
  259.  
  260. /*add Flighr
  261. *
  262. */
  263. void FlightsTL:: addNewFlight(const string& origin , const string& destination,const double& depTime, const double& duration){
  264.  
  265. Flights.push_back(Flight(origin,destination,depTime,duration));
  266. FlightsNum++;
  267.  
  268. }
  269.  
  270. /** ToString to display all flights and thier information
  271. *
  272. */
  273. string FlightsTL:: toString()const{
  274.  
  275. return "";
  276.  
  277. }
  278.  
  279.  
  280. //__________________end of FlightsTL Implementation______________\\

and the TestDriver
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5. #include<iostream>
  6. #include"Flights.h"
  7. using namespace std;
  8.  
  9. //---------------------------------------------------------------------------
  10.  
  11. #pragma argsused
  12. int main(int argc, char* argv[]){
  13. //Create a Flight object using argumets
  14. Flight b ("adl","mel",1.00,1.30);
  15. //Create a Flight object using no argumets
  16. Flight d;
  17. //Create FlightsTL object
  18. FlightsTL C;
  19. //Attempt to put Flight object into FlightsTL
  20. //there is an error when this line is uncommented
  21. C.addNewFlight("syd","per",1.00,1.30);
  22.  
  23.  
  24. cout<< "TESTING "<< d.toString()<<"\n";
  25.  
  26. system("pause");
  27. return 0;
  28. }
  29. //---------------------------------------------------------------------------



if any other problems (potential or current) are found please let me know, and give me a help hand please.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 351
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Solved Threads: 62
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: Can Anyone find the error here?

 
0
  #2
Jun 13th, 2008
You've commented out the definition of the copy constructor for Flight.
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 21
Reputation: 007tron is an unknown quantity at this point 
Solved Threads: 0
007tron 007tron is offline Offline
Newbie Poster

Re: Can Anyone find the error here?

 
0
  #3
Jun 13th, 2008
Originally Posted by Radical Edward View Post
You've commented out the definition of the copy constructor for Flight.
that helped thats
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC