K
kostyan777
Помогите пожалуйста отладить код, не могу разобраться, почему когда я создаю объект класса Sqr, который является наследником класса Poly, компиллятор ругается "cannot instantiate abstract class":
void Shapes::Add(const Poly &P)
{
if(P.name=="Квадрат")
tmp->poly=new Sqr(P);
}
Вот описание классов:
struct Pair
{
Point p;
Pair * next;
};
class Poly
{
protected:
Pair *ptr; // список точек
string name;
public:
Poly(){ptr=NULL; name="";};
Poly(const Poly&);
void Show();
double Perimetr();
virtual double Square()=0;
friend struct Shapes;
};
class Sqr: public Poly
{
public:
Sqr(){ptr=NULL; name="Квадрат";};
double Square() const;
};
Заранее благодарен.
void Shapes::Add(const Poly &P)
{
if(P.name=="Квадрат")
tmp->poly=new Sqr(P);
}
Вот описание классов:
struct Pair
{
Point p;
Pair * next;
};
class Poly
{
protected:
Pair *ptr; // список точек
string name;
public:
Poly(){ptr=NULL; name="";};
Poly(const Poly&);
void Show();
double Perimetr();
virtual double Square()=0;
friend struct Shapes;
};
class Sqr: public Poly
{
public:
Sqr(){ptr=NULL; name="Квадрат";};
double Square() const;
};
Заранее благодарен.