| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2119 人关注过本帖
标题:编译器报错不知道哪错了
只看楼主 加入收藏
a75692074
Rank: 1
等 级:新手上路
威 望:1
帖 子:48
专家分:0
注 册:2018-7-20
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:4 
编译器报错不知道哪错了
程序代码:
#include <iostream>
#include <array>
#include <cstring>
using namespace std;

const int Seasons = 4;
const array<string, Seasons> Sname = 
    {"Spring", "Summer", "Fall", "Winter"};

void fill(array<double, Seasons> *pa);
void show(array<double, Seasons> da);
    
int main()
{
    array<double, Seasons> expenses;
    fill(&expenses);
    show(expenses);
    return 0;
}

void fill(array<double, Seasons> *pa)
{
    for (int i = 0; i < Seasons; i++)
    { 
        cout << "Enter " << Sname[i] << " expenses: ";
        cin >> (*pa)[i];
    }
}

void show(array<double, Seasons> da)
{
    double total = 0.0;
    cout << "\nEXPENSES\n";
    for (int i = 0; i < Seasons; i++)
    {
        cout << Sname[i] << ": $" << da[i] << endl;
        total += da[i];
    }
    cout << "Total Expenses: $" << total << endl;
}


求大神帮忙改正一下
搜索更多相关主题的帖子: array int void double cout 
2018-07-28 16:46
a75692074
Rank: 1
等 级:新手上路
威 望:1
帖 子:48
专家分:0
注 册:2018-7-20
收藏
得分:0 
错误信息:
exercise.cpp:7:7: error: 'array' does not name a type
exercise.cpp:10:11: error: variable or field 'fill' declared void
exercise.cpp:10:11: error: 'array' was not declared in this scope
exercise.cpp:10:17: error: expected primary-expression before 'double'
exercise.cpp:10:35: error: 'pa' was not declared in this scope
exercise.cpp:11:11: error: variable or field 'show' declared void
exercise.cpp:11:11: error: 'array' was not declared in this scope
exercise.cpp:11:17: error: expected primary-expression before 'double'
exercise.cpp:11:34: error: 'da' was not declared in this scope
exercise.cpp: In function 'int main()':
exercise.cpp:15:2: error: 'array' was not declared in this scope
exercise.cpp:15:8: error: expected primary-expression before 'double'
exercise.cpp:15:8: error: expected ';' before 'double'
exercise.cpp:16:8: error: 'expenses' was not declared in this scope
exercise.cpp:17:15: error: 'show' was not declared in this scope
exercise.cpp: At global scope:
exercise.cpp:21:11: error: variable or field 'fill' declared void
exercise.cpp:21:11: error: 'array' was not declared in this scope
exercise.cpp:21:17: error: expected primary-expression before 'double'
exercise.cpp:21:35: error: 'pa' was not declared in this scope
2018-07-28 16:46
Jonny0201
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:52
帖 子:488
专家分:2603
注 册:2016-11-7
收藏
得分:4 
换编译器
你的编译器不支持 C++ 11
如果你的 IDE 老旧, 一般升级 IDE 可以解决问题
2018-07-29 09:21
Jonny0201
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:52
帖 子:488
专家分:2603
注 册:2016-11-7
收藏
得分:3 
Clang 下编译通过, gcc 没试过
2018-07-29 09:22
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:3 
回复 4楼 Jonny0201
只要不是太旧的版本,GCC肯定没问题

★★★★★为人民服务★★★★★
2018-07-29 14:08
快速回复:编译器报错不知道哪错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017224 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved