注册 登录
编程论坛 VC++/MFC

大神求助 下面这个程序不知道错在哪里呀

童木不会飞 发布于 2013-10-21 23:15, 568 次点击
#include<iostream.h>
class Volume
{privte:
int length;
int width;
int height;
int v;
public:
    void set_data();
    void figure_v();
    void show_v();
};
    void Volume::set_data()
    {cin>>length;
    cin>>width;
    cin>>height;}
    void Volume::figure_v()
    {
    v=length*width*height;}
    void Volume::show_v()
    {cout<<v<<endl;}    int main()
    {Volume v1,v2;
    v1.set_data();
    v1.figure_v();
    v1.show_v();
    v2.set_data();
    v2.figure_v();
    v2.show_v();
    return 0;}
5 回复
#2
yuccn2013-10-22 08:38
目测没有发现什么错误,楼主说的错误是什么?编译错误还是允许是有错误?

注意一下排版
#3
潇翊2013-10-22 19:11
程序代码:
//private打错了,运行至出来一个结果。
#include<iostream.h>

class Volume{
private:
    int length;
    int width;
    int height;
    int v;
public:
    void set_data();
    void figure_v();
    void show_v();
};
    void Volume::set_data(){
        cin>>length;
        cin>>width;
        cin>>height;
    }
    void Volume::figure_v(){
        v=length*width*height;
    }
    void Volume::show_v(){
        cout<<v<<endl;
    }   
int main(){
    Volume v1,v2;
    v1.set_data();
    v1.figure_v();
    v1.show_v();
    v2.set_data();
    v2.figure_v();
    v2.show_v();
    return 0;
    }
#4
童木不会飞2013-10-22 23:00
回复 2楼 yuccn
运行时说有错,还有排版要注意哪些?(我是初学者,还请多指教)
#5
童木不会飞2013-10-22 23:04
回复 3楼 潇翊
我运行了,你的是对的,可是我还是没有看出来我错在哪里呀
#6
童木不会飞2013-10-22 23:05
回复 3楼 潇翊
OK   我懂了   多谢
1