www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/07/03:25:41

Xref: news2.mv.net comp.os.msdos.djgpp:2505
From: jstev AT gladstone DOT uoregon DOT edu (Josh Stevens)
Newsgroups: comp.os.msdos.djgpp
Subject: STL problems
Date: Fri, 05 Apr 1996 07:47:40 GMT
Organization: University of Oregon Computing Center
Lines: 55
Message-ID: <4k56mb$fbp@platform.uoregon.edu>
NNTP-Posting-Host: cisco-ts6-line2.uoregon.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

OK, I tried to create a simple (trivial, really) program using STL,
like this:

/* BEGIN PROGRAM LISTING */

#include <iostream.h>
#include <stl.h>


class Print {
public:
   void operator () (int x) {
      cout << x << ' ';
   };
};


void display(const list<int>& l) {
   Print print;

   for_each(l.begin(), l.end(), print);
   cout << endl;
};


int main(void) {
   list<int> test_list;

   cout << "test_list:  ";
   display(test_list);
   for (int i = 0; i < 20; ++i) {
      test_list.push_back(i - i % 10);
   };
   cout << "test_list:  ";
   display(test_list);
   test_list.sort();
   cout << "test_list:  ";
   display(test_list);

   return 0;
};

/* END PROGRAM LISTING */

However, when executing the line "gcc test.cpp -o test.exe -Wall
-liostr", I get this error:

test.cc(.text+0x95f): undefined reference to `operator new(unsigned
long, void *)'

Does anyone know how to keep this error from occuring?  Thanks.

-Josh



- Raw text -


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