Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: string question?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string question?



cool. using the namespace thing did work. namespaces have always been that thing some people talked about, but it never affected me until now. i guess i will have to break down and learn all about namespaces and what they really are. maybe that will even be part of my class his semester. this list is so cool. thanks for the help everyone. i really appreciate it.


ryan



On Saturday, February 15, 2003, at 08:13 p, M. Uli Kusterer wrote:

compile error:
g++ -c Parser.C
Parser.C: In member function `void Parser::command(std::istream&,
std::ostream&)':
Parser.C:61: `string' undeclared (first use this function)
Parser.C:61: (Each undeclared identifier is reported only once for each
function it appears in.)
Parser.C:61: parse error before `,' token
make: *** [Parser.o] Error 1

As someone else already wrote, your error is that you're ignoring namespaces. You're supposed to *either* write std::string to access the string class, or you need to specify a "using namespace std;" after including <string> to make sure the compiler knows it's supposed to look for the symbol string in namespace std if it can't find it in the local namespace.


You might have gotten away without that so far, as the 2.x versions of GCC didn't yet support namespaces (they gracefully ignored any namespace qualifiers and treated everything as one big namespace just like in the old C days), so this might be new with GCC 3 (which arrived with 10.2, I think).

Another thing that may cause problems is your use of the suffix ".C" -- I'm not sure whether using this case-sensitive suffix works on HFS+ vlumes under OS X. It *should* work just fine, but just as a last resort, I'd try changing that to ".cp" or ".cpp" to make sure you get the C++ compiler -- some of the names are aliased to gcc, so you might be getting the C compiler by accident.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.