注册 登录
编程论坛 C++教室

让输出三个答案,但我写的只输出一个,错在哪里呢?求帮忙

hzj199603 发布于 2015-03-29 22:39, 404 次点击
#include <iostream>
using namespace std;
class volume
{
    private:
        int length;
        int width;
        int heigth;
    public:
        void set_volume(void);
        void show_volume(void);
};
int main()
{
    volume a[3];
    a[0].set_volume();
    a[0].show_volume();
    a[1].set_volume();
    a[1].show_volume();
    a[2].set_volume();
    a[2].show_volume();
}
void volume::set_volume(void)
{
    cout<<"putin length :";
    cin>>length;
    cout<<endl<<"putin width :";
    cin>>width;
    cout<<endl<<"putin heigth :";
    cin>>heigth;
}
void volume::show_volume(void)
{
    int v;
    v=length*width*heigth;
    cout<<v<<" ";
}
2 回复
#2
rjsp2015-03-30 08:26
仔细看看,不是只输出三个。
#3
诸葛欧阳2015-03-30 11:10
可以输出3个啊
1