본문 바로가기
컴퓨터과학[1-2]/knou_C++

C ++ 연습문제 풀이 4 -1

by boolean 2014. 10. 21.
728x90

#ifndef MYPAPER_H_INCLUDED

#define MYPAPER_H_INCLUDED

#include <iostream>

#include <algorithm>

using namespace std;


class Box

{

int height, width, depth;   //높이, 넓이, 깊이

int volume_content;         //상자의 체적


public:

Box();                      //생성자

~Box();                     //소멸자

void volume(int _height, int _width, int _depth);  //체적구하는 함수

void print();               //출력함수

};


Box::Box()

{


}


Box::~Box()

{


}


void

Box::volume(int _height, int _width, int _depth)

{

volume_content =_height * _width * _depth;

}


void

Box::print()

{

cout << "volume_content :" << volume_content << endl;

}

#endif


// Mypaper.cpp : Defines the entry point for the console application.

//


#include "stdafx.h"

#include <iostream>

#include "Mypaper.h"

using namespace std;



int _tmain(int argc, _TCHAR* argv[])

{

Box a1;                    //객체 선언

a1.volume(10,20,30);       //객체 사용

a1.print();                //출력

return 0;

}


댓글