Advertisement
Guest User

Include Error

a guest
Oct 24th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.52 KB | None | 0 0
  1. //This compiles if all merged into one file, it also works with a makefile, unless I add #include "finance.h" and #include "freight.h" just below this line. Both of those classes that interact with nothing as of yet. Adding them to the includes and leaving part_time.h at the bottom breaks it, putting part_time.h at the top of the includes compiles.
  2. //main.cpp
  3.  
  4. #include <iostream>
  5. #include <string>
  6. #include <stdlib.h>
  7. #include <vector>
  8. #include "casual.h"
  9. #include "dockhand.h"
  10. #include "employee.h"
  11. #include "manager.h"
  12. #include "part_time.h"
  13. using namespace std;
  14.  
  15. void add_casual()
  16. {
  17.     string name;
  18.     bool forklift;
  19.     name = "bill";
  20.     forklift = true;
  21.     Casual casual(name, forklift);
  22. }
  23.  
  24. void add_part_time()
  25. {
  26.     string name;
  27.     bool forklift;
  28.     int annual_leave;
  29.     int sick_leave;
  30.     name = "Ben";
  31.     forklift = false;
  32.     annual_leave = 1;
  33.     sick_leave = 2;
  34.     Part_time part_time(name, forklift, annual_leave, sick_leave);
  35. }
  36.  
  37. void add_dockhand()
  38. {
  39.     int dock_type;
  40.     dock_type = 1;
  41.     if(dock_type == 1)
  42.         {
  43.             add_part_time();
  44.         }
  45.         else if(dock_type == 2)
  46.         {
  47.             add_casual();
  48.         }
  49.         else
  50.         {
  51.             cout << "Sorry. Your input is invalid." << endl;
  52.             add_dockhand();
  53.         }
  54. }
  55.  
  56. void add_manager()
  57. {
  58.     string name;
  59.     name = "Bub";
  60. }
  61.  
  62. int main()
  63. {
  64.     cout << "Hello" << endl;
  65. }
  66.  
  67. //casual.h
  68. #ifndef CASUAL
  69. #define CASUAL
  70.  
  71. #include <string>
  72. #include "dockhand.h"
  73. using namespace std;
  74.  
  75. class Casual: public Dockhand
  76. {
  77.     public:
  78.         Casual (string set_name, bool set_forklift);
  79.         float min_shift;
  80.         ~Casual();
  81. };
  82.  
  83. #endif // CASUAL
  84.  
  85. //casual.cpp
  86. #include "casual.h"
  87.  
  88. Casual::Casual (string set_name, bool set_forklift) : Dockhand (set_name, set_forklift)
  89. {
  90.     min_shift = 2.00;
  91.     payrate = 26.00;
  92. }
  93.  
  94. Casual::~Casual()
  95. {
  96.  
  97. }
  98.  
  99. //dockhand.h
  100. #ifndef DOCKHAND
  101. #define DOCKHAND
  102. #include <string>
  103. #include "employee.h"
  104. using namespace std;
  105.  
  106. class Dockhand: public Employee
  107. {
  108.     public:
  109.         Dockhand (string set_name, bool set_forklift);
  110.         float start_shift;
  111.         bool forklift;
  112.         float payrate;
  113.         ~Dockhand();
  114. };
  115.  
  116. #endif // DOCKHAND
  117.  
  118. //dockhand.cpp
  119. #include "dockhand.h"
  120.  
  121. Dockhand::Dockhand (string set_name, bool set_forklift) : Employee (set_name)
  122. {
  123.     forklift = set_forklift;
  124.     start_shift = 4.00;
  125. }
  126.  
  127. Dockhand::~Dockhand()
  128. {
  129.  
  130. }
  131.  
  132. //employee.h
  133. #ifndef EMPLOYEE
  134. #define EMPLOYEE
  135. #include <string>
  136. using namespace std;
  137.  
  138. class Employee
  139. {
  140.     public:
  141.         Employee (std::string name);
  142.         string name;
  143.         ~Employee();
  144. };
  145.  
  146. #endif // EMPLOYEE
  147.  
  148. //employee.cpp
  149. #include "employee.h"
  150.  
  151. Employee::Employee (string set_name)
  152. {
  153.     name = set_name;
  154. }
  155.  
  156. Employee::~Employee()
  157. {
  158.  
  159. }
  160.  
  161. //manager.h
  162. #ifndef MANAGER
  163. #define MANAGER
  164. #include "employee.h"
  165.  
  166. class Manager: public Employee
  167. {
  168.     public:
  169.         Manager (string set_name);
  170.         float salary;
  171.         ~Manager();
  172. };
  173.  
  174. #endif // MANAGER
  175.  
  176. //manager.cpp
  177. #include "manager.h"
  178.  
  179. Manager::Manager (string set_name) : Employee (name)
  180. {
  181.     salary = 52000.00;
  182. }
  183.  
  184. Manager::~Manager()
  185. {
  186.  
  187. }
  188.  
  189. //part_time.h
  190. #ifndef PART_TIME
  191. #define PART_TIME
  192. #include <string>
  193. #include "dockhand.h"
  194. using namespace std;
  195.  
  196. class Part_time: public Dockhand
  197. {
  198.     public:
  199.         Part_time (string set_name, bool set_forklift, int annual_leave, int sick_leave);
  200.         float end_shift;
  201.         int annual_leave;
  202.         int sick_leave;
  203.         ~Part_time();
  204. };
  205.  
  206. #endif // PART_TIME
  207.  
  208. //part_time.cpp
  209. #include "part_time.h"
  210.  
  211. Part_time::Part_time (string set_name, bool set_forklift, int annual_leave, int sick_leave) : Dockhand (set_name, set_forklift)
  212. {
  213.     end_shift = 8.00;
  214.     payrate = 22.00;
  215. }
  216.  
  217. Part_time::~Part_time()
  218. {
  219.  
  220. }
  221.  
  222. //finance.h
  223. #ifndef FINANCE
  224. #define FINANCE
  225. #include <vector>
  226. #include "freight.h"
  227. #include "employee.h"
  228. using namespace std;
  229.  
  230. class Finance
  231. {
  232.     public:
  233.         Finance();
  234.         ~Finance();
  235. };
  236.  
  237. #endif // FINANCE
  238.  
  239. //finance.cpp
  240. #include "finance.h"
  241. using namespace std;
  242.  
  243. Finance::Finance()
  244. {
  245.    
  246. }
  247.  
  248. Finance::~Finance()
  249. {
  250.  
  251. }
  252.  
  253. //freight.h
  254. #ifndef PART_TIME
  255. #define PART_TIME
  256.  
  257. #include <string>
  258. using namespace std;
  259.  
  260. static const float MAX_SATCHEL_VOLUME = 0.20; // in m^3
  261. static const float MAX_CARTON_VOLUME = 0.50; // in m^3
  262.  
  263. static const float SATCHEL_COST_PER_KILO = 2.00; // in dollars
  264. static const float CARTON_COST_PER_KILO = 1.00; // in dollars
  265. static const float PALLET_COST_PER_KILO = 0.50; // in dollars
  266.  
  267. class Freight
  268. {
  269.     public:
  270.         enum FreightType
  271.         {
  272.             SATCHEL,
  273.             CARTON,
  274.             PALLET,
  275.         };
  276.         float cost()
  277.         {
  278.             return perKiloCost * weight;
  279.         }
  280.     private:
  281.         Freight (string set_address, float set_length, float set_width, float set_height, float set_weight);
  282.         string address;
  283.         float length;
  284.         float width;
  285.         float height;
  286.         float weight;
  287.         FreightType type;
  288.         float perKiloCost;
  289.         ~Freight();
  290. };
  291.  
  292. #endif // FREIGHT
  293.  
  294. //freight.cpp
  295. #include "freight.h"
  296.  
  297. Freight::Freight (string set_address, float set_length, float set_width, float set_height, float set_weight)
  298. {
  299.     address = set_address;
  300.     length = set_length;
  301.     width = set_width;
  302.     height = set_height;
  303.     weight = set_weight;
  304.     type;
  305.     perKiloCost = 1.00;
  306.         {
  307.             float volume = length * width * height;
  308.             if(volume > MAX_CARTON_VOLUME)
  309.             {
  310.                 type = PALLET;
  311.                 perKiloCost = PALLET_COST_PER_KILO;
  312.             }
  313.             else if(volume > MAX_SATCHEL_VOLUME)
  314.             {
  315.                 type = CARTON;
  316.                 perKiloCost = CARTON_COST_PER_KILO;
  317.             }
  318.             else
  319.             {
  320.                 type = SATCHEL;
  321.                 perKiloCost = SATCHEL_COST_PER_KILO;
  322.             }
  323.         }
  324. }
  325.  
  326. Freight::~Freight()
  327. {
  328.  
  329. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement