#include <iostream>
using namespace std;
class triangle
{
private:
double base;
double height;
public:
void Init(double b, double h)
{
base = b;
height = h;
}
double GetArea()
{
return(base * height) / 2.0;
}
};
int main()
{
triangle tri;
tri.Init(3, 4);
cout << "면적 : " << tri.GetArea() << endl;
return 0;
}
<실행결과>
'이것저것' 카테고리의 다른 글
[c++] 급여 계산 프로그램 (0) | 2023.03.23 |
---|