函数做参数问题
//下列段代码编译不通过,请高手指点:
// main_3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
/******************************************/
void hm_retrun(int hm_x1, int &hm_y1)
{
hm_y1 = 2*hm_x1;
}
void hm_main_test( int hm_main_x1, void hm_retrun(int hm_x1, int &hm_y1), int &hm_main_y1)
{
int hm_x1 = 3;
int hm_y1;
hm_retrun( hm_x1, hm_y1);
hm_main_y1 = hm_y1;
}
/*****************************************/
int main(int argc, char* argv[])
{
int hm_main_x1 = 1;
int hm_x1 = 3;
int hm_y1;
int hm_main_y1;
hm_main_test( hm_main_x1, hm_retrun( hm_x1, hm_y1), hm_main_y1);
}
编译时出现下列信息:
--------------------Configuration: main_3 - Win32 Debug--------------------
Compiling...
main_3.cpp
D:\Tem_test\main_3\main_3.cpp(29) : error C2664: 'hm_main_test' : cannot convert parameter 2 from 'void' to 'void (__cdecl *)(int,int &)'
Expressions of type void cannot be converted to other types
D:\Tem_test\main_3\main_3.cpp(69) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.
Creating browse info file...
main_3.exe - 1 error(s), 1 warning(s)