Using lists with OF objects

I’m running into some problems using a list to keep track of objects of a certain type. Could anyone please slap some sense into me?

I have a class ‘Circle’ and in the small game I’m trying to create, I’d like these circles to have certain behaviours. For example, all instances of Circle should be destroyed when they go off-screen.

For this purpose, I create the following:

  
		Circle *f1;  
		vector<Circle> list;  
		vector<Circle>::iterator it;  

For the sake of simplicity, I create just one instance of Circle for now in my app’s setup():

  
	f1->x = ofGetWindowWidth() * 0.5;  
	f1->y = ofGetWindowHeight() * 0.5;  
	f1->radius = ofGetWindowHeight() * 0.1;  
		  
	list.push_back(*f1);  

Here, I try to draw each instance of Circle I’m currently trying, located in my app’s draw():

  
	for (it = list.begin(); it != list.end(); ++it) {  
		it->draw(ofColor::black, true);  
	}  

The code compiles fine but crashes at runtime with exception: Unhandled exception at 0x0040C5DE in Testing_debug.exe: 0xC0000005: Access violation writing location 0xCDCDCDE1. The draw function of my Circle class takes in two parameters and have been proven to function in another app. I have no other code added, I’m testing this in an emptyExample so I’m pretty sure it’s my list implementation that’s screwed somewhere.Sorry if I’ve posted this in the wrong section.

the way you are inserting objects in the vector is kind of weird. try using non pointer Circle instances like:

  
  
Circle circle;  
circle.x=...  
list.push_back(circle);  
  

Thanks for the quick reply! Using non-pointers worked but I’m not entirely sure why my method didn’t work. I only tried to replicate what this tutorial does and no luck:
http://www.dreamincode.net/forums/topic/63358-store-class-objects-in-vector/

Time to work on some collision detection.