Hello everyone. Here is my problem.I am given four classes (Point,Shape,Circle,Rectangle)
and I must complete theme so as the program works.
Here is my project:shapes.cppCode://shapes.h #ifndef shapes_h #define shapes_h 1 class Point{ private: int x; int y; public: Point(); Point(int k, int l); ~Point(); void setX(int ); int getX() const; void setY(int ); int getY() const; void print() const; Point & operator=(const Point &p1); }; //Abstract class 2 class Shape { public: //..... virtual double Area() =0; virtual double Perifereia() =0; virtual void print() const = 0; }; 3 class Rectangle : public Shape { private: Point *myUpperLeft; Point *myLowerRight; public: double Area(); void print() const; double Perifereia(); int GetWidth() const; int GetHeight() const; Rectangle(Point *pUL, Point *pLR); }; 4 class Circle : public Shape, public Point { public: // ....... private: double radius; virtual double Area() =0; }; #endif
and main.cpp has nothing special.Code:#include <iostream> #include <cmath> using namespace std; #include "shapes.h" //Class Point Functions Point::Point(int k,int l ) {x=k;y=l;} Point::Point () {x=y=0;} Point::~Point() {} void Point::setX(int xValue) {x=xValue;} int Point::getX() const{return x;} void Point::setY(int yValue) {y=yValue;} int Point::getY() const{return y;} void Point::print()const{cout<<"["<<x<<","<<y<<"]"<<endl;} Point & Point::operator=(const Point &p1) { if(this !=&p1) { x=p1.x; y=p1.y; } return *this; } //Class Rectangle functions int Rectangle::GetWidth()const{return myUpperLeft->getX()-myLowerRight->getX();} /*line1*/ Rectangle::Rectangle(Point *pUL, Point *pLR) //error here /*line2*/ { myUpperLeft=pUL; myLowerRight=pLR; };
I use Dev-C++ and the error message is
"[Linker error] undefined reference to 'vtable for Rectangle'"



LinkBack URL
About LinkBacks



rint(void)const " (?print@Rectangle@@UBEXXZ)