흐~ 이 긴걸 도와주실 고마운분이 계실지.. T.T;
undefined symbol에러가 났습니다.
Rect.hpp내의 클래스 멤버변수(private)가 정의 되지 않았다고
나옵니다. 눈씻고 아무리 버그를 찾아봐도 도무지 모르겠습니다.
도무지 이해할수도 없고... C++를 좀 하신다면..
컴파일러를 가동하면, 변수정의 에러를 금방잡아내실 수 있을텐데..
T.T; 조금만 시간내서.. 도와주세요. 길다고 어렵게만 보지 마시고...
이건, 클래스 기본수준인데.. 도와주세요.. T.T;;
//-------------------Rect.hpp begin--------------------
#include<iostream.h>
class Point
{
public:
void SetX(int x) {itsX=x;}
void SetY(int y) {itsY=y;}
int GetX() const {return itsX;}
int GetY() const {return itsY;)
private:
int itsX;
int itsY;
};
class Rectangle
{
public:
Rectangle(int top, int left, int bottom, int right);
~Rectangle() {}
int GetTop() const {return itsTop;}
int GetLeft() const {return itsLeft;}
int GetBottom() const {return itsBottom;}
int GetRight() const {return itsRight;}
void SetTop(int top) {itsTop=top;}
void SetLeft(int left) {itsLeft=left;)
void SetBottom(int bottom) {itsBottom=bottom;}
void SetRight(int right) {itsRight=right;}
Point GetUpperLeft() const {return itsUpperLeft;}
Point GetLowerLeft() const {return itsLowerLeft;}
Point GetUpperRight() const {return itsUpperRight;}
Point GetLowerRight() const {return itsLowerRight;}
void SetUpperLeft(Point Location) {itsUpperLeft=Location;}
void SetLowerLeft(Point Location) {itsLowerLeft=Location;}
void SetUpperRight(Point Location) {itsUpperRight=Location;}
void SetLowerRight(Point Location) {itsLowerRight=Location;}
int GetArea() const;
private:
//-------------------Rect.hpp end--------------------
//------------------Rect.cpp begin-------------------
#include "Rect.hpp"
Rectangle::Rectangle(int top, int left, int bottom, int right)
{
itsTop=top;
itsLeft=left;
itsBottom=bottom;
itsRight=right;
itsUpperLeft.SetX(left);
itsUpperLeft.SetY(top);
itsUpperRight.SetX(right);
itsUpperRight.SetY(top);
itsLowerLeft.SetX(left);
itsLowerLeft.SetY(bottom);
itsLowerRight.SetX(rignht);
itsLowerRight.SetY(bottom);
}
int Rectangle::GetArea() const
{
int Width=itsRight-itsLeft;
int Height=itsTop-itsBottom;
return(Width*Height);
}
int main()
{
Rectangle MyRectangle(100, 20, 50, 80);
int Area = MyRectangle.GetArea();
cout<<"Area: " <<Area <<"\n";
cout<<"Upper Left X Coordinate: ";
cout<<MyRectangle.GetUpperLeft().GetX();
return 0;
}
int itsTop;
int itsLeft;
int itsBottom;
int itsRight;
Point itsUpperLeft;
Point itsUpperRight;
Point itsLowerLeft;
Point itsLowerRight;
};
//-------------------Rect.cpp end--------------------
|