All pastes #2051515 Raw Edit

Unnamed

public text v1 · immutable
#2051515 ·published 2011-04-28 12:29 UTC
rendered paste body
class Foo
{
public:
	Foo() { cout << "Foo constructed" << endl; }
	~Foo() { cout << "Foo destructed" << endl; }

	void say_hello() { cout << "Foo says: HELLO!" << endl; }
};
/////////////////////
int main()
{
	list<Foo*> Coll;

	for(int i=0; i<3; i++)
	{
		Foo* Temp=new Foo;
		Coll.push_back(Temp);
	}

	list<Foo*>::const_iterator pos;
	for(pos=Coll.begin(); pos!=Coll.end(); ++pos)
	{
		//delete (*pos);
		(*pos)->say_hello();
	}

	Coll.clear();
}