C++ Rotating 2D shape in list

Started by
39 comments, last by homi576 8 years ago

Hey, I'm doing the same homework as you - we're probably in the same class. I've been programming for years before starting the course, got 90%+ on our last assignment but this shapes stuff is killing me.

I've got basically the same code in my main.cpp function:


list<Shape*> shapes;
Console console;


shapes.push_back(new Rhombus(Vertex(20, 20), 8));
shapes.push_back(new Pentagon(Vertex(60, 20), 8));


list<Shape*>::iterator itr = shapes.begin();
while (itr != shapes.end())
{
(*itr)->drawShape();
itr++;
}

But whenever I launch my project, I get an error referring to 'list iterator not dereferencable' - do we need to edit the other files, such as the shapes first?

lol what are the chances, I had this error appear when the list i was using was empty.

Go through your code and make sure the shape list is being filled, look back through my posts and other posts you should find them helpful, as people start giving advice and help.

Posting more of your code would help as well, such as the shape.cpp and a rhombus.cpp etc

This topic is closed to new replies.

Advertisement