编辑代码

#include <iostream>
using namespace std;
class box
{
    public:
        int width;
        int height;
        int volume();
        box();
        box(int w, int h);
        ~box();
};
int box::volume()
{
    return width*height;
}
box::box(void)
{
    cout << "12345" <<endl;
}
box::box(int w, int h)
{
    width = w;
    height = h;
}
box::~box(void)
{
    cout << "54321" <<endl;  
}

int main() {
    box box1(10, 20);
    cout << "volume=" << box1.volume()<<endl;
    // box1.width=10;
    // box1.height=20;

    // cout << "volume=" << box1.volume(10, 33)<<endl;
    // for(int i=0; i<5; i++)
    // {
    //     cout << "zzz=" << box1.volume(10,22)<<endl;
    // }
    // cout << "\n" <<endl;
    // for(int i=0; i<5; i++)
    // {
    //     cout << "zzz=" << box1.volume(10,22)<<endl;
    // }
	return 0;
}