Errors
animshapeO.h:28: error: cannot declare parameter '<anonymous>' to be of abstract type 'shapeO' shapeO.h:3: note: because the following virtual functions are pure within 'shapeO': shapeO.h:9: note: virtual bool shapeO::collidesWith(shapeO*) p2.cpp: In function 'int main()': p2.cpp:49: error: cannot allocate an object of abstract type 'animshapeO' animshapeO.h:7: note: because the following virtual functions are pure within 'animshapeO': shapeO.h:9: note: virtual bool shapeO::collidesWith(shapeO*) p2.cpp:15: warning: unused variable 'w' p2.cpp:15: warning: unused variable 'h' animshapeO.h:28: error: cannot declare parameter '<anonymous>' to be of abstract type 'shapeO' shapeO.h:3: note: because the following virtual functions are pure within 'shapeO': shapeO.h:9: note: virtual bool shapeO::collidesWith(shapeO*) animshapeO.cpp:21: error: cannot declare parameter 'shape' to be of abstract type 'shapeO' shapeO.h:3: note: since type 'shapeO' has pure virtual functions
animshape.cpp
#include "animshapeO.h"
#include "shapeO.h"
#include <iostream>
#include <stdlib.h>
void animshapeO::update(){
x = x + movex;
y = y + movey;
}
void animshapeO::setDirectionVector(){
movex = -5 + drand48() * 10;
movey = -5 + drand48() * 10;
}
bool animshapeO::collidesWith(shapeO shape)
{
double rx,ry,rwidth,rheight;
shape.getRect(rx,ry,rwidth,rheight);
if (x+width > rx && x < rx+rwidth && x+height > rx && x < rx+ rheight)
return true;
else
return false;
return false;
}
-----------------------------------------------------------------------animshapo.h
#ifndef animshapeO_H
#define animshapeO_H
#include "shapeO.h"
class animshapeO : public shapeO
{
private:
double x,y;
double movex, movey;
public:
animshapeO() : shapeO()
{
}
animshapeO(double X , double Y, double W, double H):shapeO()
{
shapeO::setRect(X,Y,W,H);
}
void update();
void setDirectionVector();
bool collidesWith(shapeO);
};
#endif
------------------------------------------------------------------------shapeO.h
#ifndef SHAPEO_H
#define SHAPEO_H
class shapeO {
public:
shapeO() {};
virtual ~shapeO() {};
virtual bool collidesWith( shapeO *) = 0 ;
void getRect(double & X, double & Y, double & W, double & H)
{ X = x; Y = y; W = width; H = height; }
void setRect(double X , double Y, double W, double H)
{ x = X; y = Y; width=W; height=H;}
protected:
double x,y, height, width;
};
#endif











