标识符“字符串”未定义? [英] identifier "string" undefined?
本文介绍了标识符“字符串”未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误:标识符 string未定义。
但是,我包含string.h,并且在我的主文件中,一切正常。 / p>
代码:
#pragma一旦
#include< ; iostream>
#include< time.h>
#include< string.h>
班级困难
{
private:
int生活;
字符串级别;
公共:
困难(无效);
〜难度(无效);
void setLives(int newLives);
int getLives();
void setLevel(string newLevel);
字符串getLevel();
};
有人可以向我解释为什么会这样吗?
解决方案
< string.h>
是旧的C标头。 C ++提供< string>
,然后应将其称为 std :: string
。
I am receiving the error: identifier "string" undefined.
However, I am including string.h and in my main file, everything is working fine.
CODE:
#pragma once
#include <iostream>
#include <time.h>
#include <string.h>
class difficulty
{
private:
int lives;
string level;
public:
difficulty(void);
~difficulty(void);
void setLives(int newLives);
int getLives();
void setLevel(string newLevel);
string getLevel();
};
Can someone please explain to me why this is occurring?
解决方案
<string.h>
is the old C header. C++ provides <string>
, and then it should be referred to as std::string
.
这篇关于标识符“字符串”未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文