DOC

c

By Shawn Gibson,2014-03-27 19:16
18 views 0
c

#include

    #include

    class area {

    private:

     float length;

     float width;

     float height;

     float areas;

    public:

     void getnum();

     void counter();

    };

    void area:: getnum() {

     cout <<"print the length: ";

     cin >>length;

     cout <<"print the width: ";

     cin >>width;

     cout <<"print the height:";

     cin >>height;

     if(length<=0||width<=0||height<=0) {cout <<"输入有误"<

}

    void area:: counter() {

     areas=length*width*height;

     cout <<"立方体体积: "<< areas << endl;

    }

    area T;

    void main()

    {

     T.getnum();

     T.counter();

    }

    运行结果;

Report this document

For any questions or suggestions please email
cust-service@docsford.com