// ubic.h: interface for the Cubic class.
////////////////////////////////////////////////////////////////////////
#if !defined(AFX_UBIC_H__A7508557_C478_48F5_80EE_484A50FD51F0__INCLUDED_)
#define AFX_UBIC_H__A7508557_C478_48F5_80EE_484A50FD51F0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class Cubic
{
public:
void m_PrintVol();
void m_PrintArea();
Cubic(unsigned int, unsigned int, unsigned int);
Cubic();
virtual ~Cubic();
private:
unsigned int ui_Width;
unsigned int ui_Length;
unsigned int ui_Height;
};
#endif // !defined(AFX_UBIC_H__A7508557_C478_48F5_80EE_484A50FD51F0__INCLUDED_)
// ubic.cpp: implementation of the Cubic class.
//
//////////////////////////////////////////////////////////////////////
#include "ubic.h"
#include <iostream>
using namespace std;//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Cubic::Cubic()
{
ui_Length = ui_Width = ui_Height = 10;
}
Cubic::~Cubic()
{
}
Cubic::Cubic(unsigned int aWidth, unsigned int aLength, unsigned int aHeight)
{
this->ui_Height = aHeight;
this->ui_Length = aLength;
this->ui_Width =aWidth;
}
void Cubic::m_PrintArea()
{
cout << "직육면체의 표면적 : " <<
ui_Height * ui_Width * 2 + ui_Height * ui_Length * 2 + ui_Width * ui_Length * 2 << endl;
return;
}
void Cubic::m_PrintVol()
{
cout << "직육면체의 부피 : " <<
ui_Height * ui_Length * ui_Width << endl;
return;
}
#include <iostream>
#include "ubic.h"
using namespace std;
int main(void)
{
unsigned int iHeight, iLength, iWidth;
iHeight = iLength = iWidth = 0;
cout << "직육면체의 가로 세로 높이 : ";
cin >> iHeight >> iLength >> iWidth;
Cubic CDefault;
Cubic CGenerated(iHeight, iLength, iWidth);
cout << "기본 "; CDefault.m_PrintArea();
cout << "기본 "; CDefault.m_PrintVol();
cout << endl;
cout << "일반 "; CGenerated.m_PrintArea();
cout << "일반 "; CGenerated.m_PrintVol();
return 0;
}