need some help with member function pointers

I'm trying to create a class that will point one of its member functions to a member function pointer, here's a simple test to try it out:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// TEST.cpp : main project file.

class MyClass; // forward declaration

class MyClass {
	public:
	MyClass(); // constructor
	double MyClassMemberFunction(double); // this is the member funcion
	double (MyClass::*pF)(double); // this is the pointer
};

MyClass::MyClass() {
	pF = &MyClass::MyClassMemberFunction; // point to the member function..
}

using namespace std;

int main()
{
    MyClass instance; 
    return 0;
}


Compiling this I get the following error from VS2010:

1>TEST.obj : error LNK2001: unresolved external symbol "public: double __thiscall MyClass::MyClassMemberFunction(double)" (?MyClassMemberFunction@MyClass@@QAENN@Z)


This leads me to think it might not be possible to have a member function pointer inside the class, because from within the declaration it's not possible to know how much space will be required for MyClass. Is this correct?
Last edited on
You didn't define your method.
doh!
Topic archived. No new replies allowed.