Hello again, I'm trying to make a linked list that stores a bunch of shape objects that I created. The shape class is an abstract base class since it's being used as a parent class to a variety of other shape objects - but I've omitted them since they shouldn't pertain to this question.
My main question was in Picture's constructor, the compiler is giving me the error: error: expression list treated as compound expression in mem-initializer [-fpermissive].
It appears I'm getting tons of errors just coming from this one class and struct so I pasted my whole class just in case someone sees something that I didn't write correctly. I suspect all the errors I'm getting are a result of sloppy implementation in all areas on my part.
#include "Shape.cpp"
class Picture{
public:
Picture():head(0,0){} // remember to look at your node class and see how many parameters need to be passed to intialize a node
//you can ONLY have pointers and references to an abstract base class
void insert(Shape *s){head = new ShapeNode(s,head);}
double totalArea()
{
double total = 0.0;
for(ShapeNode p = head; p != 0; p = p->next)
{
total += p->info->area();
}
return total;
}
private:
struct ShapeNode
{
Shape *info;
ShapeNode *next;
ShapeNode(Shape *newInfo, ShapeNode *newNext) : info(newInfo),next(newNext){}
};
ShapeNode *head;
};
1 2 3 4 5 6 7 8 9 10 11 12 13
class Shape {
protected:
double xCoord,yCoord;
//third member
public:
Shape(double x = 0, double y = 0) : xCoord(x),yCoord(y){};
virtualdouble getX();
virtualdouble getY();
virtualdouble area() = 0;
virtualvoid draw() const = 0;
virtual ~Shape();
};