Mail Archives: djgpp/1998/01/15/07:16:34
frenchc AT cadvision DOT com (Calvin French) wrote:
>>I've experienced several problems using the C++-Containers as described in
>>the book of Stroustrup with DJGPP.
>>
>>1. stack<custom datatype> doesn't work. Is this a bug ? Or am I doing
>> something wrong ?
>I encountered this too. The answer seems to be, to specify an underlying
>CONTAINER, not datatype. Yes I think this is wierd too, but in a way it gives
>more flexibility. Remember, a stack is only a regular container with some
>restrictions. When I realized this, I decided to use a deque instead (which
>seems to cause me problems now anyways). So, in short:
The problem with the deque is simple: in deque.h you just make the
destructror deque::~deque defined inline and all is well.(I think the
problem is really in the defines or something).
The whole point of container-adoptors is that they can only be used
on containers, but a stack class is not so very difficult to code
yourself. In fact most books I have seen on C++ have one in one
of the first chapters. For instance you can simply make a template
class of the example of Lippman's on page 88 ev.
The difference between the container-adaptor and your own then is
however that you need to do memory allocation yourself(Lippmans
example makes use of a constant stacksize).
>stack< vector< my_datatype > > my_stack;
>OR
>stack< list< my_datatype > > my_stack;
>OR
>stack< my_STL_container_as_if_I_had_a_hope_in_hell_of_coding_one< my_datatype
>> > my_stack;
Heh ?? Make your own container ?? Is that possible ? If so how would
you start( is there some baseclass container ??).
>should (hopefully, fingers crossed because I'm not totally sure) do the
>trick.
>- Calvin -
- Raw text -