#include <iostream>
using namespace std;
class Shape {
public:
virtual double area() {
return 0;
}
};
class Triangle : public Shape {
private:
double base, height;
public:
Triangle(double b, double h) {
base = b;
height = h;
}
double area() override {
return (base * height) / 2;
}
};
int main() {
Shape* shape = new Triangle(10, 5);
cout << "삼각형 넓이: " << shape->area() << endl;
delete shape;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: