#include <iostream>
using namespace std;
class Rectangle {
int width, height;
public:
void set_values (int, int);
int area () {return width*height;}
};
void Rectangle::set_values (int x, int y) {
width = x;
height = y;
}
int main(int argc, char const *argv[])
{
Rectangle rect;
rect.set_values (3,4);
cout << "area is: " << rect.area() << endl;
return 0;
}
c++基础(18)
最新推荐文章于 2024-10-31 09:04:32 发布