problem declaring strings

closed account (SNbpX9L8)
for some reason i get these errors when i know everything is right..and yes i did do #include <string>

int pause;
int package;
int hours;
int amountdue;
const double package_1= 9.95, package_2= 14.95, package_3=19.95;
string name;

error: 'string' was not declared in this scope
error: expected ';' before 'name'


cout << "Please enter your name: \n";
cin >> name;

error:'name' was not declared in this scope
Have you specified the namespace for string?

1
2
3
4
5
6
7
#include<string>
using std::string;

int main() {
 string name= "";
 return 0;
}
Also, before you bother going down the cin >> name path. Read: http://www.cplusplus.com/forum/articles/6046/ to save you some hassle and headaches.
1
2
3
4
5
using std::string

or

std::string name;
Last edited on
closed account (SNbpX9L8)
thanks!!!!!!!!!
Topic archived. No new replies allowed.