标题:数组这里报错
取消只看楼主
你爸边哭边
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2017-10-30
结帖率:66.67%
已结贴  问题点数:8 回复次数:3 
数组这里报错
头文件
#include<iostream.h>
class translate
{
public:
translate()
{
    string1[9][9]={"one","two","three","four","five","six","seven","eight","nine","ten"};
    string2[9][9]={"twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"};
    string3[9][10]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","ninteen"};
}

    int num;
    void display();
    friend ostream& operator<<(ostream&output,translate &c);
private:
char string1[9][9];
char string2[9][9];
char string3[9][10];
};
。cpp文件
#include<iostream.h>
#include"translate.h"
 ostream& operator<<(ostream&output,translate &a)
{
    int c=a.num;
    if(c<11)
    output<<string1[c-1]<<endl;
    if(c>10&&c<20)
    output<<string3[c-11];
    if(c>20&&c%10!=0)
    output<<string2[c/10-2]<<' '<<string1[c%10-1]<<endl;
    if(c>=20&&c%10==0)
        output<<string2[c%10-1];
    return output;
}
void translate::display()
{
    cout<<"请输入一个0到99的数:"<<endl;
    cin>>num;

}
main函数
#include<iostream.h>
#include"translate.h"
void main()
{
    translate c;
    c.display();
    cout<<c;

}
这个程序哪里出错了?
搜索更多相关主题的帖子: 数组 include num void output 
2018-05-15 16:35
你爸边哭边
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2017-10-30
得分:0 
求大神回复
2018-05-15 20:01
你爸边哭边
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2017-10-30
得分:0 
回复 3楼 lin5161678
char应该怎么赋值呢?
2018-05-15 23:28
你爸边哭边
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2017-10-30
得分:0 
回复 5楼 lin5161678
书上没找到,能告诉我一下吗,谢谢
2018-05-16 06:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-486949-1-1.html




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

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