Trouble with .h file

Everything seems to be fine when I write out all the codes, but then when I try to compile, lots of errors concerning the 'string' identifier pops up. I have #include <string> in my .cpp files.
But the errors are still there. (I have tried with #include <string> in the .h file too but no luck)

my Pet.h file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#pragma once
class Pet
{
	string name;
	int hunger;
	int boredom;
	void passTime();
	void getMood();
public:
	Pet(string name); // input name to member 'name'
	void talk();
	void eat();
	void play();
	void touch();
};
Last edited on
The C++ string class is in the std namespace, so you need to use std::string.
Topic archived. No new replies allowed.