Hey thanks,
that is a really good site. However I think I followed what his [33.2] said, but i'm still getting an error....
Code:
#ifndef USER_H
#define USER_H
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <iostream>
using std::cout;
class USER {
private:
int *testPTR;
int test;
pthread_t thread1;
char* msg;
int iret1;
protected:
friend void* accessMemFunc(void* objPtr);
public:
USER();
~USER();
void run();
void printTest();
void start();
};
#endif
USER::USER()
{
test = 1;
testPTR = &test;
}
USER::~USER()
{
}
void USER::start()
{
USER* thisUser = this;
iret1 = pthread_create(&thread1, NULL, accessMemFunc, (void*) thisUser);
pthread_join(thread1,NULL);
return;
}
void* accessMemFunc(void* objPtr)
{
USER* objHandler = (USER*) objPtr;
objHandler->run();
}
void USER::run()
{
cout<<"thread\n";
printTest();
}
void USER::printTest()
{
cout<<"test: "<<test;
return;
}
still gets the error:
Code:
$ g++ -lpthread test.cpp
user.h: In member function ‘void USER::start()’:
user.h:44: error: ‘accessMemFunc’ was not declared in this scope
btw, my test.cpp script is this:
Code:
#include <iostream>
#include "user.h"
int main ()
{
USER testUser;
testUser.start();
return 0;
}