Im trying to write a program about a truck inventory with trucks coming and going and the amount in each one, but keep coming up with declaration syntax error.. Any help would be greatly appreciated. Im using Borland C++. Thanks
Code:
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#define max_trucks 50
class TRUCKS
{
private :
int TRUCK_NUM;
int TRUCK_CAP;
int DON_ON_HAND;
static int NUM_TRUCKS;
public :
TRUCK (int id, int don=0);
int ADD_TRUCK (int don);
int REMOVE_TRUCK (int don);
inline int GET_TRUCK_NUM () {return TRUCK_NUM;}
inline int GET_CAP () {return TRUCK_CAP;}
inline int GET_CONT () {return DON_ON_HAND;}
static int TOTAL_TRUCKS();
};
int NUM_TRUCKS = 0
{
TRUCK_NUM = id;
CAP_ON_HAND = don;
TRUCK_CAP = 250;
++NUM_TRUCKS;
}
TRUCK: :TRUCK ()
{
delete [] TRUCK_ID;
}
int TRUCK: :TOTAL_TRUCKS ()
{
return NUM_TRUCKS;
}
TRUCK* create_truck ();
void display (TRUCKS&);
truck_table
{
void main ()
create_truck,
truck_table;
int don_amt = 250,
result,
count = 0,
choice;
max_trucks;
char select = ' ';
char answer = ' ';
[max_trucks];
do
{
cout << "\n\nPlease choose a number from the menu below";
cout << "\n1. Add a truck";
cout << "\n2. Add donations to truck";;
cout << "\n3. Remove a Truck";
cout << "\n4. Display the trucks";
cout << "\n5. Quit the program";
cout << "\n\nPlease enter your selection now: ";
cin >> select;
clrscr ();
switch (select)
{
case '1':
cout << "\nDo you want to add a truck to inventory?(Y/N): ";
cin >> answer;
while (toupper(answer) == 'Y' && count, max_trucks)
{
truck_table[count] = create_truck ();
++count;
cout << "\nDo you want to add a truck to inventory?(Y/N): ";
cin >> answer;
}
break;
case '2':
cout << "\nTo whick truck would you like to add donations? (1-50) : ";
cin >> choice;
if (choice < 1 || choice > count)
{
cout << "\n\nINVALID ENTRY!!! ";
break;
}
else
{
cout << "\nPlease enter the amount of donations to add: ";
cin >> don_amt;
result = truck_table [choice - 1]->ADD_DON (don_amt);
if (result < 0)
cout << "\nERROR Truck capacity is not large enough!!!\n";
else
cout << "\nDonations added!!! ";
break ;
}
case '3' :
for (int x = 0; x < count; ++x)
display (*truck_table [x]);
break ;
}
}
while (select != '4');
cout << "\n\n\n\n THANK YOU";
cout << "\n\n GOODBYE";
for (int x = 0; x < count; ++x)
delete truck [x] ;
}
TRUCK* create()
{
int truck_num,
donations + 0;
char name [80];
TRUCK* truckptr;
cout << "\nPlease enter the truck number: ";
cin >> truck_num;
cin.ignore (81, '\n');
cout << "\nPlease enter the amount of donations in truck: ";
cin >> donations;
cin.ignore (81, '\n');
clrscr ();
truckptr = new TRUCK(truck_num, donations);
cout << "\n\nTrucks in inventory : " truckptr->TOTAL_TRUCKS ();
return truckptr;
}
void display (TRUCK& truck)
{
cout << "\n\nTruck num " << truck. GET_TRUCK_NUM ();
cout << "\nTruck capacity: " << truck. GET_CAP ();
cout << "\nDonations on hand: " << truck. GET_CONT ();
}
Comment