delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/07/19:32:11

From: Stan Moore <smoore AT exis DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: stl samples or tutorial
Date: Fri, 07 Jul 2000 19:34:42 -0400
Message-ID: <7kpcmskbn011dl4dnbn8vthnkfo1fn11vo@4ax.com>
References: <20000707085347 DOT 69858 DOT qmail AT hotmail DOT com> <000e01bfe819$4f8e1040$0307028a AT prmivv03>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
NNTP-Posting-Host: digital-2-111.exis.net
X-Trace: 7 Jul 2000 19:25:07 -0400, digital-2-111.exis.net
Lines: 43
Organization: A Customer of Exis Net Inc
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 7 Jul 2000 15:43:18 +0200, "Petr Maxa" <maxa AT sse-za DOT sk> wrote:

>Hi Nimrod,
>thanks for the source, I've compiled as You recomended, but got the same
>errors (see in atachment).
>
>Everythink works right when I change
>stack<deque<int> > s;
>for
>stack<int> s;,
>but I am not sure if it is the same.
>I do not have access to any other compiler which support stl, so I ask in
>this group.
>

I'm not sure what you mean by the same. This sample looks like it
simply tries to demonstrate the stack type. If that's the prupose of
the demo then yes it's pretty much the same. If the purpose was to
demonstate a stack of deques holding int's then it's not the same. For
what it's worth, this code compiles and runs on several compilers
(including gcc and vc) just fine here.

#include <iostream>
#include <stack>

int main (int argc, char **argv)
{
  stack<int> s;
  s.push (42);
  s.push (101);
  s.push (69);
  s.push (200);
  while (!s.empty ())
  {
    cout << s.top () << endl;
    s.pop ();
  }
  return 0;
}

Hope this in some way helped. I would suggest you read up on stacks
and deques. Then write some simple programs to play around with both
types yourself and then you'll be headed in the productive direction. 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019