home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Distribution: world
- Subject: Re: help!!!
- References: <1992Aug18.063338.21333@debbie.cc.nctu.edu.tw>
- X-Mailer: cppnews $Revision: 1.14 $
- Organization: Trumphurst Ltd.
- Lines: 61
- Date: Thu, 20 Aug 1992 16:29:08 +0000
- Message-ID: <714353348snx@trmphrst.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
-
- In article <1992Aug18.063338.21333@debbie.cc.nctu.edu.tw> cp79111@csie.nctu.edu.tw (Kuo-Ping Hsu) writes:
-
- > setvect(com_irq,&comm::NewIRQ);
- > ^^^^^^^^^^^^^
- > But the compiler reports a following error :
- >
- > Error : Connot convert 'void (far interrupt comm::*)()'
- > to 'void (interrupt far *)(...)'
- If I had a dollar for every time I had seen this question asked (AND
- answered) on the net, I'd be a rich man.
-
- I take it you do not have access to any textbooks on the C++ language, or
- to the excellent C++ FAQ (which is available for public ftp from such
- sites as uu.net). If you have, I suggest you try reading them !
-
- They will tell you (much more clearly than I am about to) that a member
- function is an entirely different thing to a regular function. A member
- function can only be called for a particular object ...
-
- class Base {
- int i;
- public:
- Base(int j = 0) : i(j) {}
- void bFunction();
- };
-
- void Base::bFunction()
- {
- cout << "Base::bFunction " << i << "\n";
- }
-
- void gFunction()
- {
- cout << "gFunction\n";
- }
-
- main()
- {
- Base b;
-
- b.bFunction(); // call bFunction for object b
- gFunction(); // regular function doesn't need an object
- bFunction(); // ERROR - no Base object supplied
- // How is bFunction going to print this->i
- // when it doesn't have a this ?
- return 0;
- }
-
- So, obviously, your interrupt handler can't call a member function,
- because it doesn't have an object to call it for.
-
- The usual solution to this problem is to make the callback function either
- global (like you would have done in good ole C) or a static member of your
- class (a static member does not need an object).
- ---
- Nikki Locke | | nikki@trmphrst.demon.co.uk
- Trumphurst Ltd. | Tel: +44 (0)691-670318 | nikki@cix.compulink.co.uk
- PC and Unix consultancy | Fax: +44 (0)691-670316 | nikki@kewill.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
- Demon.co.uk is a dial-up subscription access point to the Internet.
-