I am trying to mess around with a kind of circular logic between two classes using a function pointer. VS 6 is not cooperating or I am using improper syntax. Can someone give me an idea what is wrong?? thanks
thats the code and here is the error i get:Code:#ifndef ABC_H #define ABC_H #include <iostream.h> #include "xyz.h" class Abc { public: int truefalse(void); void call_xyz(void); private: Xyz obj_xyz; }; #endif #include "abc.h" #include "xyz.h" int Abc::truefalse(void) { int int_rc; cout << "Enter a 1 or 0: "; cin >> int_rc; cout << endl; return int_rc; } void Abc::call_xyz() { obj_xyz.what_you_picked(truefalse); } #include "abc.h" void main() { Abc obj_abc; obj_abc.call_xyz(); } #ifndef XYZ_H #define XYZ_H #include <iostream.h> class Xyz { public: void what_you_picked(int (*truefalse)(void)); }; #endif #include "xyz.h" void Xyz::what_you_picked(int (*truefalse)(void)) { if((*truefalse)()) { cout << "You Picked One" << endl; } if(!(*truefalse)()) { cout << "You Picked Zero" << endl; } }
C:\Windows\Desktop\software eng\test\abc.cpp(17) : error C2664: 'what_you_picked' : cannot convert parameter 1 from 'int (void)' to 'int (__cdecl *)(void)'
None of the functions with this name in scope match the target type




Reply With Quote