G
Guest
Please help me out of this
The purpose of the following code is to store city objects in a vector. And to make the vector independent of the existense of the dialog, it is declared as a static member. The code compiles without problem. However, it incurs a LNK2001 error when linking. Will be grateful if you tell me why and how to solve this problem?
Compiler VC6.
System WIN M
class CCit
public
CCity(){}
~CCity(){}
int CityID
double m_Longitude;
double m_Latitude
}
#include <vector
using namespace std
typedef std::vector<CCity> CityVector
class CDataInput : public CDialo
public
CDataInput(CWnd* pParent /*= NULL*/); // standard
CWnd* m_pParent
static CityVector theVector
..
void CDataInput::OnAdd()
UpdateData(TRUE)
//store the coordinate data in an CMap objec
CCity NewCity
NewCity.m_Longitude = m_CoordX
NewCity.m_Latitude = m_CoordY
NewCity.CityID++
NewCity.CityID = nCounter
nCounter++
// Append one element to the end of the vecto
theVector.push_back(NewCity)
--------------------Configuration: SplitWnd - Win32 Debug-------------------
Linking..
DataInput.obj : error LNK2001: unresolved external symbol "public: static class std::vector<class CCity,class std::allocator<class CCity>> CDataInput::theVector" (?theVector@CDataInput@@2V?$vector@VCCity@@V?$allocator@VCCity@@@std@@@std@@A
SplitWndDoc.obj : error LNK2001: unresolved external symbol "public: static class std::vector<class CCity,class std::allocator<class CCity>> CDataInput::theVector" (?theVector@CDataInput@@2V?$vector@VCCity@@V?$allocator@VCCity@@@std@@@std@@A
Debug/SplitWnd.exe : fatal error LNK1120: 1 unresolved external
Error executing link.exe
SplitWnd.exe - 3 error(s), 0 warning(s
The purpose of the following code is to store city objects in a vector. And to make the vector independent of the existense of the dialog, it is declared as a static member. The code compiles without problem. However, it incurs a LNK2001 error when linking. Will be grateful if you tell me why and how to solve this problem?
Compiler VC6.
System WIN M
class CCit
public
CCity(){}
~CCity(){}
int CityID
double m_Longitude;
double m_Latitude
}
#include <vector
using namespace std
typedef std::vector<CCity> CityVector
class CDataInput : public CDialo
public
CDataInput(CWnd* pParent /*= NULL*/); // standard
CWnd* m_pParent
static CityVector theVector
..
void CDataInput::OnAdd()
UpdateData(TRUE)
//store the coordinate data in an CMap objec
CCity NewCity
NewCity.m_Longitude = m_CoordX
NewCity.m_Latitude = m_CoordY
NewCity.CityID++
NewCity.CityID = nCounter
nCounter++
// Append one element to the end of the vecto
theVector.push_back(NewCity)
--------------------Configuration: SplitWnd - Win32 Debug-------------------
Linking..
DataInput.obj : error LNK2001: unresolved external symbol "public: static class std::vector<class CCity,class std::allocator<class CCity>> CDataInput::theVector" (?theVector@CDataInput@@2V?$vector@VCCity@@V?$allocator@VCCity@@@std@@@std@@A
SplitWndDoc.obj : error LNK2001: unresolved external symbol "public: static class std::vector<class CCity,class std::allocator<class CCity>> CDataInput::theVector" (?theVector@CDataInput@@2V?$vector@VCCity@@V?$allocator@VCCity@@@std@@@std@@A
Debug/SplitWnd.exe : fatal error LNK1120: 1 unresolved external
Error executing link.exe
SplitWnd.exe - 3 error(s), 0 warning(s