Reputation: 33
I cant seem to figure this out, its probably simple. I have a customer class and I am trying to create an object form that and its not working I get an undeclared identifier error and a syntax error ; missing before identifier c1. thanks
class Customer{
string customerID;
string list;
public:
Customer(void);
~Customer(void);
string getcustomerID(){
return customerID;
}
string getList(){
return list;
}
void setcustomerID(string x){
customerID = x;
}
void setList(int x){
if(x==1)
list = "bread";
if(x==2)
list = "eggs";
if(x==3)
list = "cheese";
}
};
void checkout(){
srand(time(NULL));
int random = rand() % 3 + 1;
Customer c1;
c1.setcustomerID(0);
Upvotes: 0
Views: 45
Reputation: 10378
You need a default constructor (and a destructor). If you want a really simple one (and make it compile) just do this:
Customer() {}
~Customer() {}
EDIT: KerrekSB is right, on this particular case you are better off not defining or declaring either of them.
Upvotes: 2