c++ structure

Bananapie

New Member
I keep getting the error
Code:
prog5.cc:18:5: error: expected unqualified-id before â.â token
prog5.cc:19:5: error: expected unqualified-id before â.â token
prog5.cc:20:5: error: expected unqualified-id before â.â token
prog5.cc:21:5: error: expected unqualified-id before â.â token
prog5.cc:26:24: error: expected primary-expression before â)â token

and it is revolving around my structure lines, where I try putting elements into the variables, as well as when I push the object cust into my list. The code is as follows

Code:
// structure for individual customer
typedef struct {
    int id;                         // customer id
    int atime, wtime, s_checkout;   // customer arrival time, wait time in
                                    // checkout, and time to enter checkout line
} cust;

Code:
int main()
{//begin main

srand(SEED);
int clock = 0; //starting simulation clock

cust.id = 1;        //THIS IS LINE 18
cust.atime = 0;  //first customer enters at 0
cust.wtime = 0;  //update wtime later
cust.s_checkout = start_checkout(clock);  //gets RNG for the customer to get
                                        //groc. items and enter checkout line
list<cust> custList;
queue<cust> custQ;

custList.push_back(cust); //puts in first customer

return 0;
}//end main

From my understanding, I am putting the elements in correctly.

The point is to fill the variables in the structure, and then put that customer into a list.

Not sure why I am getting the error. Anyone have a clue?
 
Last edited:
You have to create a variable of type cust.

Code:
// structure for individual customer
typedef struct {
    int id;                         // customer id
    int atime, wtime, s_checkout;   // customer arrival time, wait time in
                                    // checkout, and time to enter checkout line
} cust;

int main()
{//begin main
srand(SEED);
int clock = 0; //starting simulation clock

cust customer;

customer.id = 1;        //THIS IS LINE 18
customer.atime = 0;  //first customer enters at 0
customer.wtime = 0;  //update wtime later
customer.s_checkout = start_checkout(clock);  //gets RNG for the customer to get
                                        //groc. items and enter checkout line
list<cust> custList;
queue<cust> custQ;

custList.push_back(customer); //puts in first customer

return 0;
}//end main
 
Back
Top