반응형
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
class Point
{
private:
int xpos, ypos;
public:
Point (int x, int y):xpos(x),ypos(y)
{ }
void ShowPointInfo()const
{
cout << "[" << xpos << "," << ypos << "]" << endl;
}
};
class Circle
{
private:
int rad;
Point center;
public:
Circle (int x, int y, int r):rad(r),center(x,y)
{ }
void ShowCircleInfo()const
{
cout << "radius: " << rad << endl;
center.ShowPointInfo();
}
};
class Ring
{
private:
Circle inCircle;
Circle outCircle;
public:
Ring(int inx, int iny, int inr, int outx, int outy, int outr):inCircle(inx,iny,inr), outCircle(outx, outy, outr)
{}
void ShowRingInfo()const
{
cout << "Inner Circle Info..." << endl;
inCircle.ShowCircleInfo();
cout << "Cuter Circle Info..." << endl;
outCircle.ShowCircleInfo();
}
};
int main()
{
Ring ring(1, 1, 4, 2, 2, 9);
ring.ShowRingInfo();
return 0;
}
반응형
'Programming > C++' 카테고리의 다른 글
열혈c++ Chapter03 문제03-2 1번 2번 (0) | 2021.08.15 |
---|---|
열혈c++ 문제 4-1 , 4-2 (0) | 2021.08.15 |
열혈c++ 4-3 2번문제 (0) | 2021.08.15 |
c++ winmain (0) | 2021.08.15 |
모던 c++ 챌린지 3이나 5로 나누어떨어지는 자연수의 합 , 최대공약수, 최소공배수 (0) | 2021.08.15 |