LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 869|回复: 1

一个C++程序在ANJUTA中!

[复制链接]
发表于 2003-6-8 10:52:29 | 显示全部楼层 |阅读模式
#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
发表于 2003-6-8 11:53:10 | 显示全部楼层
因为根据标准,包含文件是没有.h的,应该是
#include <iostream>
using namespace std;
名称空间看你喜欢什么样的用法了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表