2013-06-27 4 views
1

템플릿을 사용하고 있지 않으며 정적 클래스 또는 함수가 아니므로 정의시 LNK2001 오류가 발생하는 이유를 알 수 없습니다. 다음은 전체 오류입니다.해결되지 않은 외부 기호가 정의 되었더라도?

1>mapgenerator.obj : error LNK2019: unresolved external symbol "private: class std::vector<int,class std::allocator<int> > __thiscall MapGenerator::Decode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" ([email protected]@@[email protected][email protected]@[email protected]@@[email protected]@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@Z) referenced in function "private: void __thiscall MapGenerator::GenerateTileLayer(class TiXmlNode *)" ([email protected]@@[email protected]@@Z) 

My MapGenerator 클래스; 이 불평하는 이유

class MapGenerator 
{ 
public: 
    //Constructor and destructor 
    MapGenerator(std::string tmxfile) : doc(tmxfile.c_str()) { Load(); } 
    ~MapGenerator(); 

    //Loads in a new TMX file 
    void Load(); 

    //Returns a map 
    void GetMap(); 


    //Reads the TMX document 
    void Read(); 


private: 
    //The TMX document 
    TiXmlDocument doc; 



    //Generates a tile layer 
    void GenerateTileLayer(TiXmlNode* node); 

    //Generates a tileset 
    void GenerateTileset(TiXmlNode* node); 

    //Generates an Object Layer 
    void GenerateObjectLayer(TiXmlNode* node); 

    //Generates a Map Object(Goes in the object layer) 
    void GenerateObject(TiXmlNode* node); 

    //Decodes the data 
    std::vector<int> Decode(std::string data); 

    bool loadOkay; 


}; 

그리고 cpp를 첨부 정의,

std::vector<int> Decode(std::string data) 
{ 
    //Represents the layer data 
    std::vector<int> layerdata; 

    //Decodes the data 
    data = base64_decode(data); 

    //Shift bits 
    for(unsigned int i = 0; i < data.size(); i+=4) 
    { 
     const int gid = data[i] | 
       data[i + 1] << 8 | 
       data[i + 2] << 16 | 
       data[i + 3] << 24; 

     //Add the resulting integer to the layer data vector 
     layerdata.push_back(gid); 

    } 

    //Return the layer data vector 
    return layerdata; 
} 

이 같은 함수를 호출하고,

std::string test(node->FirstChild("data")->Value()); 
data = Decode(test); 

나는 때 모든 것을 확실하지 않다 적합 해 보입니다. 참고로, 나는 함수가 const char * const 대신 std :: string 대신 Value() 반환하지만 LNK2001 오류가 나타납니다 이후 만들기 시도했다. 아이디어가 있으십니까?

+4

'MapGenerator ::'를 (Decode의) 정의에 추가하는 것을 잊었습니다. –

답변

5
std::vector<int> Decode(std::string data) 

:: 범위 결정 연산자 클래스 이름이 있어야합니다.

std::vector<int> MapGenerator::Decode(std::string data) 
        //^^^^^ 

MapGenerator 클래스의 멤버 함수이기 때문에.

+0

나는 내가 어리 석다는 것을 알았다. 감사! –

+1

@DanielMartin 우리는 슈퍼맨이 아니기 때문에 실수합니다. 천만에요. – taocp

4

당신은 수행해야합니다

std::vector<int> MapGenerator::Decode(std::string data) 
{