class Customer{
public:
Customer(){};
Customer(int i)
{id=i;}
~Customer(){...};
static void* run(void* arg)
{
//code for execution
return NULL;
}
private:
static int id;
}
int main(void)
{
int index;
int status;
//Create Customer Threads
pthread_t Customer_Threads[50];
Customer *Customers;
Customers=new Customer[50];
// create 50 Customer threads
for (index = 0; index < 50; index++) {
Customers[index]=*new Customer(index);
status = pthread_create (&Customer_Threads[index], NULL, Customers[index].run, NULL);
assert(0 ==status);
}
}
My question is when i try to use pthread_create to call function in class Customer, the error pop up about 'undefined reference to Customer::~A()'' and 'undefined reference to `Customer::A()''.
I want to create an array of class Customer object, and use multi_thread to execute the run function in class Customer, i don't know how to deal with these errors. Thanks.
I use C++ in Xcode and compile in linux.
-----------------Update-------------------
Now i still face an error 'undefined reference to `Customer::id''.
Not sure why.