밑변 과 높이? 구하는것 ....

 

헤드 파일 만들어서 제작

 

/* R04.h */

class Triangle

{

public:

Triangle( int w, int h ) : width( w ), height( h ) {}

int area() { return w * h / 2; }

 

private:

int width;

int height;

};

 

class Rectangle

{

public:

Rectangle( int w, int h ) : width( w ), height( h ) {}

int area() { return w * h; }

 

private:

int width;

int height;

};

 

/* R04.cpp */

#include <iostream.h>

#include "R04.h"

 

int main()

{

Triangle tri( 4, 3 );

Rectangle rect( 4, 3 );

 

cout << "밑변 4, 높이 3인 삼각형의 넓이는 " << tri.area() << " 입니다. " << endl;

cout << "밑변 4, 높이 3인 사각형의 넓이는 " << rect.area() << " 입니다. " << endl;

return 0;

}

 

 

by 리베리온 2013. 12. 29. 23:36