|
#include <iostream.h>
typedef unsigned short int USHORT;
enum BOOL { FALSE, TRUE };
class Rectangle
{
public:
Rectangle(USHORT width, USHORT height);
~Rectangle() {}
void DrawShape() const;
void DrawShape(USHORT aWidth, USHORT aHeight) const;
private:
USHORT itsWidth;
USHORT itsHeight;
};
Rectangle::Rectangle(USHORT width, USHORT height)
{
itsWidth = width;
itsHeight = height;
}
Rectangle::DrawShape() const /* 이 부분에서 DrawShape() 이
{ rectangle 의 멤버가 아니라면서 컴파일이
안됩니다. */
DrawShape(itsHeight, itsWidth);
}
void Rectangle::DrawShape(USHORT height, USHORT width) const
{
for(USHORT i=0;i<height;i++)
{
for(USHORT j=0;j<width;j++)
{
cout << "*";
}
cout << "\n";
}
}
int main()
{
Rectangle theRect(30,5);
cout << "DrawShape(): \n";
DrawShape();
cout << "\nDrawShape(40,2): \n";
DrawShape(40,2);
return 0;
}
이유가 무엇이며 어떻게 해결해야 하나요? 답변 부탁드려요.
|