728x90
#include <iostream>
using namespace std;

class Rectangle {
private:
	int width, height;
public:
	Rectangle(int w, int h);
	int getArea();
};

Rectangle::Rectangle(int w, int h)
	: width(w), height(h) {}

int Rectangle::getArea() 
{
	return width * height;
}

int main()
{
	int x, y;
	cout << "가로 세로 입력 >>";
	cin >> x >> y;

	Rectangle rect(x,y);
	

	cout << "사각형의 면적은 " << rect.getArea() << endl;
}

반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기