~cpp #include <iostream> using namespace std; class CRectangle { private: int width; int height; public: CRectangle(); CRectangle(int x, int y); int GetWidth(); int GetHeight(); int GetBorderLength(); int GetArea(); void Draw(); void SetRect(int x, int y); }; CRectangle::CRectangle() { width = 0; height = 0; } CRectangle::CRectangle(int x, int y) { width = x; height = y; } void CRectangle::Draw() { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) cout << "*"; cout << endl; } } int CRectangle::GetWidth() { return width; } int CRectangle::GetHeight() { return height; } int CRectangle::GetBorderLength() { return 2 * (width + height); } int CRectangle::GetArea() { return width * height; } void CRectangle::SetRect(int x, int y) { width = x; height = y; } int main() { CRectangle rect1(3, 3); CRectangle rect2; rect2.SetRect(4, 5); cout << "rect1의 가로길이 : " << rect1.GetWidth() << endl; cout << "rect1의 세로길이 : " << rect1.GetHeight() << endl; cout << "rect1의 둘레길이 : " << rect1.GetBorderLength() << endl; cout << "rect1의 넓이 : " << rect1.GetArea() << endl; rect1.Draw(); cout << "rect2의 가로길이 : " << rect2.GetWidth() << endl; cout << "rect2의 세로길이 : " << rect2.GetHeight() << endl; cout << "rect2의 둘레길이 : " << rect2.GetBorderLength() << endl; cout << "rect2의 넓이 : " << rect2.GetArea() << endl; rect2.Draw(); return 0; }