<p>I am implementing a BFS, and what it is going to do is go through an ordered tree to find the shortest solution to a puzzle.</p>

<p>What i will be doing is creating a Snapshot object that holds the current position of each piece in a puzzle. I will add this Snapshot object into the queue and check if it is the solution. However, I am creating these snapshots on the fly. So is there some kind of way that will automatically generate the names of the Snapshot objects when they are put into the queue?</p>

<p>or do i have to keep track of how many declarations i have made and just hard code it by saying...</p>

<p>Snapshot snapshot2;
Snapshot snapshot3;
Snapshot snapshot4;
etc..</p>

You could use a queue from the standard template library, then create a function that creates a Snapshot object and puts in into the queue.  Give this function a static variable which gets incremented every time it is called and written into an id field of the snapshot.
http://www.csci.csusb.edu/dick/samples/stl.html
http://www.cppreference.com/wiki/stl/queue/start