क्यों जब मैं दृश्य स्टूडियो में इस संकलन करने की कोशिश मैं लिंकर त्रुटि मिलता है 2008स्थिर एसटीडी के साथ अजीब लिंकर त्रुटि :: नक्शा
#include <stdafx.h>
#include <iostream>
#include <map>
#include <string>
class MyClass
{
public:
MyClass() { };
virtual ~MyClass() {};
static std::string niceString (std::map<int, int> mappp) { _myMap = mappp; return "nice string"; };
private:
static std::map<int, int> getMap () { return _myMap; };
static std::map<int, int> _myMap;
};
int main(){
std::map<int, int> mappp;
mappp[1] = 1;
std::cout << MyClass::niceString(mappp);
}
त्रुटि है:
Error 1 error LNK2001: unresolved external symbol "private: static class std::map<int,int,struct std::less<int>,class std::allocator<struct std::pair<int const ,int> > > MyClass::_myMap" ([email protected]@@[email protected][email protected]@[email protected]@[email protected][email protected][email protected]@@@[email protected]@[email protected]@A) test22.obj test22
अनिवार्य रूप से [स्टेटिक स्ट्रक्चर लिंकर त्रुटि] का एक डुप्लिकेट (http://stackoverflow.com/questions/1850809/static-struct-linker-error) दूसरों के बीच। – Troubadour
संभावित डुप्लिकेट [सी ++ में स्थिर सदस्यों को परिभाषित करना] (http://stackoverflow.com/questions/3536372/defining-static-members-in-c) –