글
밑변 과 높이? 구하는것 ....
헤드 파일 만들어서 제작
/* 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;
}
'컴퓨터 > c관련 숙제' 카테고리의 다른 글
윈도우 프로그래밍 (0) | 2013.12.29 |
---|---|
윈도우 프로그래밍 숙제 2탄~! (0) | 2013.12.29 |
c언어 자료구조 숙제~! 1부 (0) | 2013.12.29 |
c언어 자료구조 숙제 ~! 2부 (0) | 2013.12.29 |
자료구조) (큐+스택) 이중연결리스트를 이용한 덱프로그램 (0) | 2013.12.29 |
RECENT COMMENT