[TriLUG] The C++ STL library

Ed Hill ed at eh3.com
Thu Dec 4 15:59:07 EST 2003


On Thu, 2003-12-04 at 15:44, Ralph Blach wrote:
> Is the C++ stl included in redhat 9.0.  If it is, how do i compile with it.
> If not where do I get the source?


Recent versions of GCC come with an STL implementation since its part of
the C++ standard.  So if you install all of the GCC packages (including
"libstdc++-devel-3.2.2-5"), then the headers you need are there.

Heres a quick demo of how to use them:

cat <<EOF > test.cpp
#include <vector>
#include <iostream>
int main(int argc, char ** argv) {
  std::vector<double> v;
  for (int i=0; i<3; i++) {
    v.push_back(double(i) + 100.5);
    std::cout << i << ": " << v[i] << std::endl;
  }
  return 0;
}
EOF

make test
./test

hth,
Ed

-- 
Edward H. Hill III, PhD
office:  MIT Dept. of EAPS;  Room 54-1424;  77 Massachusetts Ave.
            Cambridge, MA 02139-4307
email:   eh3 at mit.edu,  ed at eh3.com
URL:     http://web.mit.edu/eh3/
phone:   617-253-0098
fax:     617-253-4464
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.trilug.org/pipermail/trilug/attachments/20031204/2f135442/attachment.pgp>


More information about the TriLUG mailing list