Cannot use string - am using #include<string>

Feb 19, 2013 at 6:52am
Hello.

I am trying to make a simple little game in c++ for practice purposes. However, I cannot use the string class for reasons I am unable to determine. Here is the relevant code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<string>
#ifndef GAMEPLAY_H_
#define GAMEPLAY_H_

class Gameplay {

private:
	string playerName;
public:
	void NewGame();

};

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<string>
#include"Gameplay.h"

using namespace std;

void Gameplay::NewGame(){
	cout << "Welcome to the Potion Game. \n";
	cout << "In this game you will gather ingredients to make potions. \n";
	cout << "It\'s very simple. \n\n";
	cout <<"Before you begin, will you please tell me your name?";
	cin >> playerName;

	return;
}


When I try to compile the code in Microsoft Visual Basic 2010, I get an error saying that playerName is missing a type identifier. I do not know why it is not recognizing the string class. Could someone please tell me what I am doing wrong here?

(I am sure that there are multiple problems with my code; however, I would sincerely appreciate if I could receive assistance with this problem before moving on to others.)
Last edited on Feb 19, 2013 at 6:55am
Feb 19, 2013 at 6:55am
it's std::string

or do your using namespace thing before the Gameplay class is defined.


EDIT:
Microsoft Visual Basic 2010


This will not compile in Visual Basic because it's not Visual Basic. It's C++

;P
Last edited on Feb 19, 2013 at 6:56am
Feb 19, 2013 at 6:57am
Thank you very much. I did the latter, and it worked. The help is greatly appreciated.
Topic archived. No new replies allowed.