1. ## Homework project(need help)

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:
Code:
```   //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:
virtual double Area() =0;
};
#endif```
shapes.cpp
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;
};```
and main.cpp has nothing special.

I use Dev-C++ and the error message is
"[Linker error] undefined reference to 'vtable for Rectangle'"

2. hmm... Dev-C++? If I remember correctly there was some strange bug such that a custom class with the name "Rectangle" causes problems. You may have to change the class name, or perhaps place it in some namespace (recommendation not tested).

EDIT:
Okay, I did a test and could not duplicate the error that I had with a class named "Rectangle" some time back. It could be that I am mistaken.

3. Well,maybe. In fact, I tested it in MS Visual C++ and the message is
shapes.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Rectangle:rint(void)const " (?print@Rectangle@@UBEXXZ)
shapes.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Rectangle::Area(void)" (?Area@Rectangle@@UAENXZ)
Debug/main.exe : fatal error LNK1120: 2 unresolved externals

4. Another bug in the "flawless" devC++. It would not hurt to have a back up IDE. Code::blocks is quite good as is any MS one apart from version 6.0. Bloodshed have abandoned working on DevC++. 4.992 the final version. It has a few bugs still, which were never filtered out. Most of the help files are missing or painfully incomplete too. As Laserlight pointed out.

5. Maybe swgh. But my PROBLEM is that allthough line1 works line2 doesn't. Any ideas?

6. do you have a body for Area function in Rectangle class?

7. Wait - Rectangle is an abstract base class itself, since you did not implement some of the virtual functions inherited from Shape. I jumped to a premature conclusion.

May I suggest a few changes? For one thing, you might want to improve your code formatting to make your code easier to read: one reason why I made my earlier assumption was that I could not be bothered to examine your code carefully in the messed up form that was displayed in my browser.

Also, Point does not need to define a copy assignment operator or a destructor as the compiler generated versions will work perfectly fine.

8. Well I haven't completed it yet. I guess I would write in shapes.cpp
Code:
`int Rectangle::GetHeight()const{  return myUpperLeft->getY()  -  myLowerRight->getY();  }`
and then
Code:
`double Rectangle::Area{return GetWidth() * GetHeight()}`

9. Well I tried to make it a bit more readable. And as for the destructors and constructors I don't care since they do not create any problems.