|
#include <iostream.h>
void function1 (int );
void function2 (int );
void function3 (int );
int main (void)
{
void (*f[3])(int)={function1,function2,function3};
int choice;
cout <<"Enter a number between 0 and 1, 2 to end: ";
cin >>choice;
while (choice>=0 && choice <3)
{
(*f[choice])(choice);
cout <<"Enter a number between 0 and 1,2 to end: ";
cin >> choice;
}
cout << "rogram execution completed." << endl;
return 0;
}
void function1 (int a)
{
cout << "You entered " << a
<< "so function1 was called\n\n";
}
void function2 (int b)
{
cout << "You entered " << b
<< "so funciont2 was called\n\n";
}
void function3 (int c)
{
cout << "You entered " << c
<< "so function3 was called\n\n";
}
这样的程序.为什么有这样的警告呢? |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|