C++ include files

Posts: 133
Joined: 2008.05
Post: #16
And since it wasn't mentioned, your file should be a .cpp and not a .c, as you pointed out in a previous post. Unless you tell the compiler to compile all files as C++ source files, but the XCode default uses whatever extension the file is.
Quote this message in a reply
Posts: 1,140
Joined: 2005.07
Post: #17
In order to recognize the string object, you need to put the line
using namespace std;
after you include <string>. Either that, or use std::string instead of just string.
Quote this message in a reply
Posts: 78
Joined: 2004.06
Post: #18
Sic, that would do the trick. Thanks!

When in doubt ... read the Read Me
10.5.6 | MacBook Pro 2.5x2 | 4 GB RAM | GeForce 8600M GT
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #19
#include <string>

then you can either refer to std::string everywhere, or add

using std::string;

after the include and before you need it.

You should never put a "using" declaration in a header!

[edit]You should also avoid "using namespace" unless you have very good reason to...[/edit]
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Include in Xcode Atomical 19 8,656 Jul 8, 2005 04:56 PM
Last Post: Atomical