I upgraded to vs2008 and now I can delcare and int, bool, or any primative data type, but when I delare a string it wont let me.

int ip; Works
char ip; Works

string ip; DOES NOT WORK

I get these three errors.

error C2146: syntax error : missing ';' before identifier 'ip
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Recommended Answers

All 4 Replies

Dude.. Try this

#include <string>

using namespace std;

It gets included by default.

It gets included by default.

really?

With

#include <iostream>
using namespace std;

some of the string functionality is available. But not all. I can allocate and assign strings, and access string function. But curiously, iostream overloads are not available with including <string>.

I suppose it's a matter of what you're defining as "by default".

#include<string> 
using namespace std;

I reckon you should try it even if you think it is included by default, it may be the answer.

Also, check all your ;'s are in the correct places.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.