发布网友 发布时间:2024-10-23 23:27
共1个回答
热心网友 时间:2024-11-02 06:07
#include <iostream>
using namespace std;
class Box {
private :
int length;
int width;
int heigth;
public :
Box(int len = 0,int w = 0,int h = 0);
void print();
int volume();
~Box() {}
};
Box::Box(int len,int w,int h) {
length = len;
width = w;
heigth = h;
}
void Box::print() {
cout << length << "," << width << "," << heigth << endl;
}
int Box::volume() {
return length * width * heigth;
}
int main() {
Box A(2,3,5);
A.print();
cout << A.volume() << endl;
return 0;
}