[C/C++] Intereseting compile error of Passing function pointer as an argument of template class member...

Language/C&C++ 2009.09.28 23:31

[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]
 

In MSVC 2008 Express, following code raises error.

template  class A
{
    int   Func(int (*f)(const T, const T));
}

static int TagF(const Tag* a, const Tag* b){...}

int main()
{
    A a;
    a.Func(TagF); // error : type of 1st parameter is mismatch...bla-bla...
}

Intersetingly, following is well-compiled in MSVC 2008 Express.

// Definition of Class A is same with above.

typedef Tag*  PTag;
static int TagF(const PTag a, const PTag b) {...}

int main()
{
    A a;
    a.Func(TagF);
}

Is it a bug of MSVC? or Do I miss something????

신고
tags : , ,
Trackback 0 : Comment 0