2011-12-13 3 views
2

DLL이 포함 된 실행 파일로 작업하고 있습니다. 내 테스트 케이스의 경우 코드를 단일 실행 파일로 결합했다. Visual Studio 2008 및 Boost 1.43에서 작업하고 있습니다. 나는 이것에 대한 연구를 해보았지만 분명한 대답을 찾지 못했다. 도와 주셔서 감사합니다. 내 MAIN.CPP에서Typedef 함수 포인터가 클래스 멤버를 가리킬 수 있습니까?

#include <string> 

//These are normally defined in a seperate DLL 
typedef std::string Typedef_func(const std::string & title); 
void Register_My_Typedef(Typedef_func*); 
//------------------------------------------- 

class myClass 
{ 
public: 
    std::string func_one(const std::string & title); 

    Typedef_func _test; 

    void run(); 
}; 

:

내 main.h에서

Register_My_Typedef가 아닌 클래스의 함수를 호출 할 때 DLL 논리가 잘 작동

#include "main.h" 
#include <boost/bind.hpp> 

std::string workingFunc(const std::string & title) 
{ 
    return ""; 
} 

int main(int argc, char* argv[]) 
{ 
    myclass* example; 
    example->run(); 

    Register_My_Typedef(&workingFunc);//This works. 

    return 0; 
} 

void myClass::run() 
{ 
    //I want to point a Typedef_func* in a DLL to call myclass::func_one 
    Typedef_func* tf = boost::bind(&myClass::func_one, this, "test"); //This does not. 

    Register_My_Typedef(tf); 
} 

std::string myClass::funcOne(const std::string & title) 
{ 
    return ""; 
} 

void Register_My_Typedef(Typedef_func* passedIn) 
{ 
    //Points the pointer in the DLL to passedIn 
} 

, 그러나 그것은이다 수업 시간에 전화 할 수 있습니까? 나는 그것을 반환이 코드를 컴파일 할 때 : 내가하려고하면

및 VS2008와 Windows XP에서 컴파일 내가 얻을 : '초기화': C2440은

오류 에서 변환 할 수 없습니다 '는 :: _ BI를 높일 수 : ::: [ R = 표준 : 문자열 (__cdecl *) Typedef_func '에서'bind_t ' F = _ :: MFI :: MF1가 L = 부스트 : _ 쌍방향 ::리스트 2가 향상 부스트 : _ BI 값> ]

이 작업을 수행 할 수있는 사용자 정의 변환 연산자를 사용할 수 없습니다. 변환 또는 연산자를 호출 할 수 없습니다. 자체 그러나 다르게 비 정적에 정적 멤버 함수 &없이 행동에 대한 클래스 멤버 오히려 사용자 정의 클래스의 기본 클래스 기능을 읽는 가장 적합한 형식 정의

답변

관련 문제