But i keep getting an error saying that
where 'ClientSocket' is the name of my class.error: argument of type `void (ClientSocket::)(int)' does not match `void*'
What is the right way to get my C++ member functions to be called on interrupt signals?
where 'ClientSocket' is the name of my class.error: argument of type `void (ClientSocket::)(int)' does not match `void*'
Code: Select all
#include<signal.h>
#include<unistd.h>
#include<iostream>
using namespace std;
class A{
static int Timeout;
public:
A()
{
signal(SIGALRM,Alarm);
}
static void Alarm(int signum)
{
Timeout++;
cout<<"In alarm handler"<<endl;
}
void Test()
{
cout<<"In Test()"<<endl;
alarm(4);
while(!Timeout);
cout<<"Leaving Test"<<endl;
}
};
main()
{
A a;
a.Test();
}
I tried the following out but get a linker error
Code: Select all
static int Timeout;
Code: Select all
class A{
static int Timeout;
...
}
int A::Timeout; // <- you need this