P
Peter Oliphant
Here is a simplification of my code. Basically, I have a class (A) that can
be constructed using a function pointer to a function that returns a bool
with no parameters. I then want to create an instance of this class (A) in
another class (B) which uses one of its own methods of the 'proper form' to
initialize the instance. But I get an error:
__gc class ClassA
{
public:
ClassA( bool (*func)(void) ) {//---some code---//} // constructor
} ;
__gc class ClassB
{
public:
void Method_B1( )
{
class_a = new ClassA( Method_B2 ) ; // error C2664
}
private:
bool Method_B2( ) {{//---some code---//}
ClassA* class_a ;
} ;
error C2664: 'ClassA::ClassA(bool (__cdecl *)(void))' : cannot convert
parameter 1 from 'bool (void)' to 'bool (__cdecl *)(void)
What is going on here, and what do I need to fix this (i.e., allow me to
pass such a method)?
be constructed using a function pointer to a function that returns a bool
with no parameters. I then want to create an instance of this class (A) in
another class (B) which uses one of its own methods of the 'proper form' to
initialize the instance. But I get an error:
__gc class ClassA
{
public:
ClassA( bool (*func)(void) ) {//---some code---//} // constructor
} ;
__gc class ClassB
{
public:
void Method_B1( )
{
class_a = new ClassA( Method_B2 ) ; // error C2664
}
private:
bool Method_B2( ) {{//---some code---//}
ClassA* class_a ;
} ;
error C2664: 'ClassA::ClassA(bool (__cdecl *)(void))' : cannot convert
parameter 1 from 'bool (void)' to 'bool (__cdecl *)(void)
What is going on here, and what do I need to fix this (i.e., allow me to
pass such a method)?