| www.delorie.com/archives/browse.cgi | search |
| From: | "Wes Kurdziolek" <wesk AT widomaker DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| References: | <370982e5 DOT 13785014 AT news DOT wanadoo DOT fr> |
| Subject: | Re: Help with C++ library |
| Date: | Wed, 7 Apr 1999 00:20:34 -0400 |
| Lines: | 69 |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2014.211 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2014.211 |
| NNTP-Posting-Host: | pm11-42.wmbg.widomaker.com |
| Message-ID: | <370ade14.0@newnews.widomaker.com> |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
The reason that you're getting errors in comilation is b/c everything in the
C++ standard library is packaged into the std namespace. You're program
needs to be written like this:
#include <iostream>
#include <string>
using namespace std; // I'm not sure if G++ for DJGPP supports this
// Otherwise you'll have to prefix
all of your
// standard library references w/
std::
int main()
{
string str0 = "Hello, ";
string str1 = "boys!";
cout << str0 + str1 << endl;
return 0;
}
Wes
Gallicus <Gallicus AT caramail DOT com> wrote in message
news:370982e5 DOT 13785014 AT news DOT wanadoo DOT fr...
> I use the last version of Djgpp.
> C programs works OK.
>
> I am testing the C++ library.
>
> To test the C++ I wrote :
> #include <iostream.h>
> int main() {
> int a = 100, b=200;
> cout << "Hello " << a + b << endl;
> return 0;
> }
> It works OK.
>
> To test the String C++ class I wrote:
> #include <iostream>
> #include <_String.h>
> int main() {
> String str = "Hello ";
> String str1 = "boys!";
> cout << str + str1 << endl;
> return 0;
> }
> Compiling is OK. Linking aborts.
> I get : undefined reference to "String:: ...."
>
> To test the C++ Integer class I wrote :
> #include <Integer.h>
> int main() {
> Integer a = 100;
> Integer b = 200;
> cout << a + b << endl;
> return 0;
> }
> Compiling is OK. linking aborts.
> I get undefined reference to "Integer::..."
>
> What is the problem ?
>
> TIA.
> Gallicus.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |