Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!hsdndev!husc3.harvard.edu!husc10.harvard.edu!king1 From: king1@husc10.harvard.edu (Gary King) Newsgroups: comp.lang.c++ Subject: G++ question Keywords: G++, C++ Message-ID: <1991May6.183253.880@husc3.harvard.edu> Date: 6 May 91 22:32:52 GMT References: <74609@brunix.UUCP> Sender: king1@husc7.harvard.edu (gary king) Followup-To: king1@husc7.harvard.edu Organization: Harvard University Science Center Lines: 67 Nntp-Posting-Host: husc10.harvard.edu HI, I'm using the following C++ class to interface to the interval timer and the SIGALRM signal in UNIX. g++ doesn't mind the header file and it doesn't mind the constructor, but when it gets to int ticker::sethandler( void (*f)(int) ) it complains: ticker.cc: 'f' undeclared, outside of functions ticker.cc: parse error before ')' Can anyone explain this and what to do to make it work. Thanks in advance.... (truncated code appears below): /* ** ticker class ** This class is an interface to the UNIX ** alarm system call. Only one is allowed at a ** time so we make everything in it static. */ #include class ticker { public: ticker( int, void (*f) (int) ); ~ticker(); // user interface ... static int sethandler( void (*) (int) ); private: static void set_ticker( int = 0 ); static int ticks; // how often to go off static void (*handler)(int); // what to do when we ring }; :::::::::::::::::: ticker.cc :::::::::::::::::: #include #include #include "ticker.h" void syserr( char * ); ticker :: ticker( int ticktock, void (*func) (int) ) { ticker :: ticks = ticktock; ticker :: handler = func; signal( SIGALRM, ticker :: handler ); } ... ... ... static int ticker :: sethandler( void (*xll)(int) ) { signal( SIGALRM, (ticker :: handler = func ) ); return 0; }