I can’t quite seem to figure out why this doesn’t work. I tried to make a queue of pointer types and it failed. I have a class Room, and I want to make a queue of pointers to Room.. so I did:
queue<*Room> bfsRooms;
this gave me the error:
`*’ cannot appear in a constant-expression
Does this mean it is impossible to make a STL queue of pointers?
No it should be fine, you should really link the exact code and exact error so we can help you better.
That said a queue of pointers would look something like this:
EDIT: it is worth noting that if these pointer own their objects they point to you should really encapsulate the pointer in a smart pointer, something like:
This abide by the RAII principle and will automatically clean up resources.