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?



I think you might need a "using namespace std;" in there somewhere. Either that, or specify each string as "std::string".

-Neil

On Saturday, February 15, 2003, at 09:51  PM, Ryan McNeal wrote:

well, i tried using <string.h> and <string> in my #includes. but i have had no luck. below is the compile error and below that are my header and implementation codes. i am just completely clueless as to why 'string' is undeclared when i have a #include<string> in the Parser.h file.

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


Parser.h: #include<iostream.h> #include<ctype.h> #include<string>

class Parser
{
 public:
  void process(istream& inP, ostream& outP);

 private:
  void command(istream& inP, ostream& outP);
};

Parser.C:
#include"Parser.h"

void Parser::process(istream& inP, ostream& outP)
{
   char ch;

  while(inP.get(ch))
  {
    if(ch == '\\')
    {
      command(inP, outP);
    }
    else
    {
      outP << ch;
    }
  }
}

void Parser::command(istream& inP, ostream& outP)
{
  char ch;

  // eof while in command mode - print error and dump.
  if(!inP.get(ch))
  {
    cerr << "oops...Didn't finish that command there did you?\n"
         << "tsk, tsk, tsk...Maybe next time, huh?" << endl;
    return;
  }

  // Eat WS, otherwise move along.
  while(isspace(ch))
  {
    inP.get(ch);
    if(!isspace(ch))
    {
      inP.unget();
      return;
    }
  }

// the def command.
if(isalnum(ch))
{
string name, // <--- this is line 61 compile error : Parser.C:61: `string' undeclared
expansion;
}


  // No cases, i guess we can go home.
  outP << ch;
  return;
}



thanks again for any help yall.

ryan
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: string question? (From: Ryan McNeal <email@hidden>)



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.