Can I dynamically allocate std::queue?
I'm having problems with templates blah blah blah.. lack of understanding.. confusion etc etc.
I want to create a queue object from the Standard Template Library for a type of my own classes. I've got it to compile but I get a segmentaion fault whenever I try and do anything with the instantiated queue. Even if I try to make a std::queue of int I get a segmentation fault. This is what I have done :
std::queue<int,std::deque<int> >* intQueue;
And finally in an instance method where I want to do something with the queue:
std::queue<int,std::deque<int> >* intQueue = new std::queue<int,std::deque<int> >();
Whatever I do with the queue intQueue, I get a segmentation fault. I can't seem to find examples of how to allocated a template on the HEAP, all text books just show it on the STACK. Is it possible to allocate on the HEAP and if so what am I doing wrong ?
intQueue->push(dcnt); // This gives segmentation fault
I'm using gcc under Linux (Ubuntu)