我做了一個類。頭文件是:C++ Visual Studio類錯誤標識符字符串未定義
#pragma once
#include <string>
class Player
{
public:
Player();
private:
};
和cpp文件是:
#include "Player.h"
#include <iostream>
Player::Player()
{
}
當我定義在頭文件中的字符串並添加參數在頭文件中的一切玩家功能工作正常
#pragma once
#include <string>
class Player
{
public:
Player(string name);
private:
string _name;
};
但是當我相同的參數添加到播放器的功能在cpp文件
#include "Player.h"
#include <iostream>
Player::Player(string name)
{
}
我收到一個錯誤:標識符「字符串」是未定義的,我也在頭文件中得到了同樣的錯誤,所以它也影響到了這一點。我試圖在cpp文件中包含字符串以期解決問題,但它不起作用。我非常渴望解決方案,夥計們。
它遺漏之前'string'的命名空間。你嘗試過'std :: string'嗎? http://www.cplusplus.com/reference/string/string/ – Caramiriel 2015-02-08 14:06:50
我懷疑標題更改是否按您所說的那樣工作! – 2015-02-10 15:07:45