我有以下類:stringstream導致鏈接錯誤?
#ifndef CGE_NET_MESSAGE_PARSER_HPP
#define CGE_NET_MESSAGE_PARSER_HPP
#include "Game/platform.hpp"
#include <vector>
#include <string>
#include <sstream>
namespace cge
{
class NetMessageParser
{
static std::stringstream ss;
static void clearStream();
public:
NetMessageParser(void);
static int parseInt(const std::string &str);
static float parseFloat(const std::string &str);
static double parseDouble(const std::string &str);
static std::vector<int> parseIntVectorString(
std::string str, char startKey, char endKey, char separator);
static std::string numberToString(int n);
static std::string numberToString(float n);
static std::string numberToString(double n);
virtual ~NetMessageParser(void);
};
}
#endif
將會產生下面的鏈接器錯誤:
Error 3 error LNK2001: unresolved external symbol "private: static class std::basic_stringstream,class std::allocator > cge::NetMessageParser::ss" ([email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@A) NetMessageParser.obj
出了什麼問題?
這有什麼好做'的std :: stringstream'錯誤。你只是沒有正確閱讀C++書中關於如何定義靜態成員的章節。關於這個問題有一百萬億美元的問題。 –
@Tomalak Geret'kal對不起。 – jmasterx