홈 > IT > IT정보
IT정보

[C++] Circle 객체 b를 a에 더하는 예제코드

3 Selovic 0 26 0 0
#include <iostream>
using namespace std;
class Circle
{
	int radius;
public:
	Circle(int r) { radius = r; }
	int getRadius() { return radius; }
	void setRadius(int r) { radius = r; }
	void show() { cout << "반지름이 " << radius << "인 원" << endl; }
};
void increaseBy(Circle& a, Circle& b)
{
	int r = a.getRadius() + b.getRadius();
	a.setRadius(r);
}
int main()
{
	Circle x(10), y(5);
	increaseBy(x, y);
	x.show();
}

0 Comments
Category
Facebook Twitter GooglePlus KakaoStory KakaoTalk NaverBand
PlusFriend Chat