#ifndef MIGRATINGUSER_H
#define MIGRATINGUSER_H
#include <iostream>
using namespace std;
class MigratingUser
{
public:
void populateUidAndGuid(string line);
private:
string uid;
string guid;
};
#endif
,且s頭定義和下面是CPP定義:未定義參照現有類
#include "MigratingUser.h"
using namespace std;
void MigratingUser::populateUidAndGuid(string line)
{
//get the uid and guid
}
,這是我正的誤差。我怎麼能解決此問題:
undefined reference to MigratingUser::populateUidAndGuid(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
的完整性,這是我如何使用類:
MigratingUser muser;
muser.populateUidAndGuid(temp);
你有沒有'#include'?在頭文件中使用namespace std;' –
2012-02-02 02:51:24
如果你的代碼被拆分成多個cpp文件,你是否正確鏈接了目標文件?你用什麼命令編譯? – stefanB 2012-02-02 02:51:52
不,我沒有包括由於命名空間標準的字符串。什麼是好的做法?的std :: string? – DarthVader 2012-02-02 02:52:35