String class for g++ under OSX?

Kinniken

Registered
Hi, does anyone know if a string class similar to the one available for many UNIX (AIX in my case) exists for the mac?
I have a university project based on it I need to work on at home, and without the class I'm stuck.
And no, I can't redo it with pointers ;)

TIA,

Kinniken
 
as far as i know it is "built in" with g++. you just need to do a #include <string>

you probably need to add a "using namespace std or else use the full qualifier. your c++ file might look like this...

PHP:
 #include <iostream>
#include <string>
 
using namespace std;

int main(){
  string s = "happy happy";

  cout << s << endl;
}
 
Thanks! That was indeed it. My test program (very similar to yours) now work. :)
However, I have an other strange mistake I did not get using g++ at University:

the line (in a .C):

void Parseur :: parse (const string & fname) {

where Parseur is a custom class, gives me the following error:

Parseur.C:9: parse error before `&' token

Any ideas?

TIA,

Kinniken
 
i'm shooting in the dark, but here is my best effort.

i'm assuming that you have this function declaration and the function implementation seperate. my only guess is that you are passing have it as pass by reference (&) in one spot and not the other. thats all i've got for you though. good luck.
 
Nope, that's not it. I checked, the declaration and implementation are the same, and anyway the error message does not fit. Good attempt ;)
Well, you solved my first problem (and thanks, I doubt I would have thought of that), I'll try to solve this myself.

Kinniken
 
Back
Top