delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/10/31/21:02:02

From: "Charlie Hall" <chazhall AT extra DOT mindspring DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need help - String Class (compiling/linking)
Date: Tue, 31 Oct 2000 19:22:48 -0500
Organization: MindSpring Enterprises
Lines: 60
Message-ID: <8tnnpk$61u$1@slb1.atl.mindspring.net>
References: <8tndkb$pu7$1 AT slb1 DOT atl DOT mindspring DOT net> <39ff50ed DOT 52358905 AT news DOT freeserve DOT net>
NNTP-Posting-Host: 3f.34.0b.be
X-Server-Date: 1 Nov 2000 00:23:16 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I tried what you suggested, and now I get the following error messages:

    In function 'int main()':
    'String' undeclared (first use this function)
    parse error before '('

By the way, I get the same errors when I run it directly from RHIDE.

You mentioned that _String.h is just a DJGPP thing.  What is <string>?  Is
it the "standard C++" string class header?

Any thoughts?

Thanks,
Charlie


Steamer <dontmailme AT iname DOT com> wrote in message
news:39ff50ed DOT 52358905 AT news DOT freeserve DOT net...
> Charlie Hall wrote:
>
> >I've successfully written and run programs that use <iostream.h>,
>
> <iostream.h> is non-standard, so it's better to use <iostream>.
> (Remember, however, that this puts everything in namespace std.)
>
> >and I've just attempted to use the String class,
> >which I assume is in <_String.h>.
>
> <_String.h> is just a DJGPP thing - what you want is <string>.
>
> > Here's my code:
> >
> >     // Program:  list.cpp
> >     #include <_String.h>
> >
> >     int main()
> >     {
> >         String s1('a');
> >         return 0;
> >     }
>
> Try this:
>
>
> #include <string>
> using std::string;
>
> int main()
> {
>     string s1("a");
>     return 0;
> }
>
>
> Compile like this:
>
>     gpp -Wall -O2 list.cpp -o list.exe


- Raw text -


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