함수 부분을 이해를 못하신거네요...
사실 에러 메세지에 설명이 다 나와 있는건데..
책에서..
함수 부분에서 프로토 타입 or 함수 원형에 대해서 찾아보세요..
c장군 님이 쓰신 글 :
: 소스는 인포북에 있는 것이고요. 그런데, 컴파일러는 에러메세지를 냅니다.
: 소스는 다음과 같습니다.
: #include <iostream.h>
: typedef unsigned short int USHORT;
:
: class Rectangle
: {
: public:
: Rectangle(USHORT width , USHORT height);
: ~Rectangle(){}
:
: void DrawShape() const;
: void DrawShape(USHORT width , USHORT height) const;
:
: private:
: USHORT Width;
: USHORT Height;
: };
:
: Rectangle::Rectangle(USHORT width , USHORT height)
: {
: Width = width;
: Height = height;
: }
:
: void Rectangle::DrawShape() const
: {
: DrawShape(Width , Height);
: }
:
: void Rectangle::DrawShape(USHORT width , USHORT height) const
: {
: for(USHORT i=0 ; i<height ; i++)
: {
: for(USHORT j=0 ; j<width ; j++)
: {
: cout << "*";
: }
: cout << "\n";
: }
: }
:
: void main()
: {
: Rectangle theRect(30,5);
:
: cout << "DrawShape()\n" << DrawShape() << endl;
:
: cout << "\nDrawShape(40,2)\n" << DrawShape(40,2) << endl;
: }
: 에서 컴파일 에러메세지는
: Error : Function "DrawShape" should have a prototype.
: 이라고 출력됩니다.
: 어디서 무엇이 문제인지 좀 어렵네요.
|