I'd rather spend my energy fixing your REAL code than the abhoration that is an example of HOW NOT TO DO THINGS.
Show an example of what you REALLY want to do, and I'll help you.
This works for me, based on your original code (but compressed into one file to make life easier for me, as I generally have a few dozen small projects in one directory, and it's hard enough without each project having 4 different "bits" to track):
Code:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
class TestClass
{
public :
void add();
void SayHelp(std::vector<std::string>* vv1);
private:
int m_test;
};
typedef void (TestClass::*FredMemFn)(std::vector<std::string>* vv);
class TestMethod
{
public :
void Init(TestClass& o, FredMemFn p,std::vector<std::string>* vv);
private :
TestClass* m_TestClass;
};
#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
void callit(TestClass& o, FredMemFn p,std::vector<std::string>* vv)
{
CALL_MEMBER_FN(o,p)(vv);
}
void TestMethod::Init(TestClass& o, FredMemFn p,std::vector<std::string>* vv1)
{
int h = vv1->size();
callit(o,p,vv1);
}
void TestClass::SayHelp(std::vector<std::string>* vv)
{
std::cout << "Help" << std::endl;
}
void TestClass::add()
{
std::vector<std::string> vv1;
vv1.push_back("DDDD");
TestMethod* testMethod = new TestMethod();
FredMemFn p = &TestClass::SayHelp;
testMethod->Init(*this,p,&vv1);
}
int main()
{
TestClass t;
t.add();
}
Of course, it won't work with a thread function because you need to use static. But none of the above looks like anything that you would sensibly feed as a thread anyways, so I don't see the point of "converting it" to anythings else.
--
Mats