鱼C论坛

 找回密码
 立即注册
查看: 5029|回复: 1

C++ 错误-error: functional cast expression list treated as compound expression

[复制链接]
发表于 2014-4-29 20:56:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 小水 于 2014-4-29 20:58 编辑

编译出现错误,求大神讲解error: functional cast expression list treated as compound expression
函数实现功能:输入员工的姓名,出生日期(月/日),按日期大小输出员工姓名
代码:
#include<iostream>
using namespace std;
struct Employ{
        string a;
        int mouth;
        int day;
};
void sort(Employ e[],int n)
{
        Employ temp;
        for(int i=0;i<n;i++)
                {        temp.a=e[i].a;
                        temp.mouth=e[i].mouth;
                        temp.day=e[i].day;
                        for(int j=i+1;j<0;j++)
                        {
                        if(temp.mouth>e[j].mouth)
                                        {temp.mouth=e[j].mouth;
                                        temp.day=e[j].day;
                                        temp.a=e[j].a;
                                        }
                                if(temp.mouth==e[j].mouth){
                                        if(temp.day>e[j].day)
                                        {
                                                temp.a=e[j].a;
                                                temp.day=e[j].day;
                                        }
                                }
                        }
                        cout<<temp.a<<temp.mouth<<temp.day<<endl;                                

                }
}
int main()
{
        int num;
        cout<<"please intput the number of employ"<<endl;
        cin>>num;
        Employ e_num[num];
        for(int i=0;i<num;i++)
        {
               
                cout<<"please input the name of "<<i+1<<"  employ "<<endl;
                cin>>e_num[i].a;
                cout<<"please input the mouth of "<<i+1<<"  employ (1-12)"<<endl;
                cin>>e_num[i].mouth;
                cout<<"please input the day of "<<i+1<<"  employ (1-31)"<<endl;
                cin>>e_num.day;
                cout<<endl;
        }
        void(e_num,num);
        return 0;
}



[/i][/i][/i][/i][/i]
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-4-29 21:54:38 | 显示全部楼层

回帖奖励 +5 鱼币

     程序没大问题,就是小错误有点多
  1. #include <iostream>
  2. #include <string>

  3. using namespace std;

  4. struct Employ
  5. {
  6.         string a;
  7.         int mouth;
  8.         int day;
  9. };

  10. void sort(Employ e[],int n)
  11. {
  12.         Employ temp;
  13.         for(int i=0;i<n;i++)
  14.         {      
  15.                         temp.a=e[i].a;
  16.             temp.mouth=e[i].mouth;
  17.             temp.day=e[i].day;
  18.             for(int j=i+1;j<0;j++)
  19.             {
  20.                                 if(temp.mouth>e[j].mouth)
  21.                 {
  22.                                         temp.mouth=e[j].mouth;
  23.                                         temp.day=e[j].day;
  24.                     temp.a=e[j].a;
  25.                 }
  26.                 if(temp.mouth==e[j].mouth)
  27.                                 {
  28.                                         if(temp.day>e[j].day)
  29.                     {
  30.                                                 temp.a=e[j].a;
  31.                         temp.day=e[j].day;
  32.                     }
  33.                 }
  34.             }
  35.             cout<<temp.a<<' '<<temp.mouth<<' '<<temp.day<<endl;                                

  36.        }
  37. }

  38. int main()
  39. {
  40.         int num;
  41.         cout<<"please intput the number of employ"<<endl;
  42.         cin>>num;
  43.                 cout<<endl;
  44.         Employ e_num[100];

  45.         for(int i=0;i<num;i++)
  46.         {
  47.                
  48.                 cout<<"please input the name of "<<i+1<<"  employ "<<endl;
  49.                 cin>>e_num[i].a;

  50.                 cout<<"please input the mouth of "<<i+1<<"  employ (1-12)"<<endl;
  51.                 cin>>e_num[i].mouth;

  52.                 cout<<"please input the day of "<<i+1<<"  employ (1-31)"<<endl;
  53.                 cin>>e_num[i].day;

  54.                 cout<<endl;
  55.         }

  56.         sort(e_num,num);

  57.         return 0;
  58. }
复制代码
建议楼主建立良好的代码风格和谨慎的态度
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-21 05:28

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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