Hi,
Another help plz... How to send a function/module as parameter? I know to do it in C but how in C++? :|
My code(C),
#include <stdio.h>
void print(char* s)
{
printf("Print = %s",s);
}
//------------------------------------
void process(void(*k)())
{
(*k)("C++ or C?n");
}
//------------------------------------
void main()
{
process(print);
}
//------------------------------------
Visual C++ error if written as C++ code(.cpp),
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
d:rubishdfcpp1.cpp(11) : error C2197: 'void (__cdecl *)(void)' : too many actual parameters
d:rubishdfcpp1.cpp(16) : error C2664: 'process' : cannot convert parameter 1 from 'void (char *)' to 'void (__cdecl *)(void)'
None of the functions with this name in scope match the target type
Error executing cl.exe.
Cpp1.exe - 2 error(s), 0 warning(s)
Function As Parameter
Moderator: Board moderators