首页 > 试题广场 >

有以下程序 #include using...

[单选题]
有以下程序
#include <iostream>
using namespace std;
_______________________
void One(float one)
{ 
    cout<<"1"<<endl;    
}
void Two(float two)
{ 
    cout<<"2"<<endl; 
}
void Three(float three)
{ 
    cout<<"3"<<endl; 
}
int main() 
{  
    float i=1,j=2,k=3;
   function = One;
   function(i);
   function= Two;
   function(j);
   function = Three;
   function(k);
}
请为横线处选择合适的程序使得程序的运行结果是123   (      )
  • void *function();
  • void *function(float);
  • void (*function)();
  • void (*function)(float);
考察 指针型函数 和 指向函数的指针 指针型函数:函数类型 *函数名(){} 在函数结束时把大量的数据从被调函数返回到主调函数中 指向函数的指针: 函数类型(*函数指针名)() 函数指针名=函数名
发表于 2021-11-22 19:15:31 回复(0)
<p>B的写法是一个指针函数,返回一个指针,D才是一个函数指针</p>
发表于 2021-01-01 11:10:03 回复(0)
function是函数指针,类型为void
发表于 2019-08-05 20:13:48 回复(0)
函数指针调用时不需要显式解引用
发表于 2025-10-29 12:59:39 回复(0)
这个确实盲区了,没怎么写过函数指针
发表于 2023-03-09 21:16:20 回复(0)
function是函数指针,类型为void;回调函数
发表于 2022-04-12 17:15:23 回复(0)
这儿不应该用*function吗
发表于 2021-09-20 12:19:32 回复(0)