Topic: GNU string class question/problem


Author: fjh@cs.mu.OZ.AU (Fergus Henderson)
Date: Tue, 7 Sep 1993 09:19:00 GMT
Raw View
cbladow@velveeta.apdev.cs.mci.com (Chad_Bladow) writes:

>I am using GNU C++ version 2.4.3.1. I am trying to use the string class
>supplied in the GNU libraries (String).
>In the sample program below I get the following errors:
>error.cc: In function `int  main ()':
>error.cc:18: void value not ignored as it ought to be
>
>If I use the commented code it seems to behave just fine.
>Why to I get these errors?????  8-(

It's because libg++ defines the assignment operators to return ``void''
instead of returning a reference to the result.  I don't know
why the authors of libg++ decided to do that, you'd have to ask them.
The following code will work:

    String str = "this is a string";
    while (str = str.after(RXwhite), str != "")
       cout << str << endl;





Author: cbladow@velveeta.apdev.cs.mci.com (Chad_Bladow)
Date: Thu, 2 Sep 1993 15:20:56 GMT
Raw View
I am using GNU C++ version 2.4.3.1. I am trying to use the string class
supplied in the GNU libraries (String).
In the sample program below I get the following errors:
error.cc: In function `int  main ()':
error.cc:18: void value not ignored as it ought to be
error.cc:18: ambiguous pointer conversion

If I use the commented code it seems to behave just fine.
Why to I get these errors?????  8-(

Please reply to the email address below.
Thanks in advance 8-)

#include <stdlib.h>
#include <String.h>
#include <Regex.h>

main()
{
   String  str;
   char in[40] = "this is a string";
   str = in;

//   str = str.after(RXwhite);
//   while(str != "")
//     {
//      cout << str << endl;
//      str = str.after(RXwhite);
//     }

   while ((str = str.after(RXwhite)) != "")
      cout << str << endl;
}

********************************************************************
*  Chad Bladow
*  MCI Communications Corp
*  Email - cbladow@chong.snms.cs.mci.com  or  cbladow@mcimail.com
*  Phone - (719)-535-5336
*******************************************************************