Author Topic: Pointers To Member Functions  (Read 1441 times)

anphanax

  • Member
  • **
  • Posts: 197
  • Kudos: 11
    • http://june.tripod.com
Pointers To Member Functions
« on: 17 February 2004, 22:48 »
These Are Both Members Of the wlWindow Class:

 
quote:

// Declaration of member function.
LRESULT CALLBACK fProc(unsigned int);

// Failed attempt to define a member of
// another class with a pointer to
// public function.
xClass.xfProc   = &wlWindow::fProc;



Here's my error    
"Cannot convert long (pascal wlWindow::*)(unsigned int) to long(pascal *)(unsigned int)"

After reading a ton of stuff online, talking to people in chatrooms, and referring to c++ documentation, I still don't know how to fix this (or how to cast it properly). If anyone could help, it would be greatly appreciated.

Edit: The people in the chatrooms were basically useless (didn't know c++ period yet they were in a programming chatroom), and the guides online never mentioned anything like this.

[ February 17, 2004: Message edited by: anphanax ]


flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
Pointers To Member Functions
« Reply #1 on: 18 February 2004, 00:15 »
Can you post some more code? What's xClass? What type is xfProc?
"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca


solo

  • Member
  • **
  • Posts: 344
  • Kudos: 1
    • http://www.komodolinux.org/
Pointers To Member Functions
« Reply #2 on: 6 March 2004, 06:23 »
The class type is part of the type of the function pointer. This is severely annoying but you must declare the pointer with the class type too. For instance:

Code: [Select]


At least I THINK thats the syntax. That very much limits what you can do but in order for the function to access the other data in the class it's necessary. That said it may not be necessary if someFunc() was declared static. Im not sure. Ill get back to you.
Komodoware, moving Linux to your desktop.
http://www.komodoware.com/