From: authentic AT tip DOT nl (Rick) Newsgroups: comp.os.msdos.djgpp Subject: Re: C++-Container-Trouble Date: Wed, 14 Jan 1998 12:01:55 GMT Organization: NL-NIC Lines: 49 Message-ID: <69ktst$3h7$1@cadmium.aware.nl> References: <69d8am$hlg$1 AT nz12 DOT rz DOT uni-karlsruhe DOT de> <34bd78ff DOT 0 AT news DOT cadvision DOT com> Reply-To: authentic AT tip DOT nl NNTP-Posting-Host: nijmegen-009.std.pop.tip.nl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 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 -