MegaJohn (30.08.2011 12:16, просмотров: 182) ответил =AlexD= на testA.init() как описан? Что она должна принимать?
выше ссылка на тестовый проект для MSVC2008. Но если у вас его нет, то вот всё[+] ====================main.c======================
clsA
testA;
clsB
testB;
////////////////////////////////////////////////////////////////////////////////
void A2B_through_C( void )
{
testB.exec();
}
////////////////////////////////////////////////////////////////////////////////
int _tmain( int argc, _TCHAR* argv[] )
{
testA.init( &A2B_through_C ); // а как бы сделать напрямую testA.init( &testB.exec() ) ???
while( !kbhit() );
return 0;
}
====================stdafx.h======================
typedef void(*func_ptr)( void );
// TODO: reference additional headers your program requires here
class clsA {
public:
clsA();
void init( func_ptr );
};
class clsB {
public:
clsB();
void exec( void );
};
====================stdafx.cpp======================
///////////////////////////
clsA::clsA()
{
}
void clsA::init( func_ptr in_func_ptr )
{
printf( "A_init\r\n" );
in_func_ptr();
}
///////////////////////////
clsB::clsB()
{
}
void clsB::exec( void )
{
printf( "B_exec\r\n" );
}