본문 바로가기

언어/C++

원 가게 상속 와플 만들기 !

#include <iostream>
#include <string>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

class Circle{
	int radius;
public:
	Circle(int radius=0) {
		this->radius=radius;
	}
	int getRadius(){
		return radius;
	}
	void setRadius(int radius){
		this->radius=radius;
	}
	double getArea(){
		return 3.14*radius*radius;
	}
};

class NamedCircle : protected Circle{
	string name;
	
public:
	
	NamedCircle(int radius,string name): Cirlce(int radius){
		this->name=name;
	}	
	void show()
	{
		cout<< "반지름이 " << getRadius() << "인 " << name << endl; 
	}	
};


int main() {
	
	NamedCircle waffle(3, "waffle");
	waffle.show();
}