EssentialC++PractiseFor4.3 error LNK2001: 无法解析的外部符号 "private: static class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,enum GlobalWrap::uLevel,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,enum GlobalWrap::uLevel> > > GlobalWrap::_user_level_map" (?_user_level_map@GlobalWrap@@0V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4uLevel@GlobalWrap@@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4uLevel@GlobalWrap@@@std@@@2@@std@@A)EssentialC++PractiseFor4.3 fatal error LNK1120: 1 个无法解析的外部命令

解决方案 »

  1.   

    具体怎么操作呢?只有map这一个静态变量编译不过去,其他的静态变量都是正常的啊。
      

  2.   

    class   GlobalWrap 
    {
    ...
    static map<string, enum uLevel> _user_level_map; //这个叫静态变量的声明
    }; map<string, enum uLevel> GlobalWrap::_user_level_map;//这个叫静态变量的定义
      

  3.   

    #include "stdafx.h"
    ……
    using namespace std;class GlobalWrap
    {
    public:
    ……
    private:
    //以下部分是为了解决4.4中的问题。
    enum uLevel  { Beginner, Intermediate, Advanced, Guru };
    static map< string, enum uLevel  > _user_level_map;};
    map <string,   enum   uLevel>   GlobalWrap::_user_level_map;
    编译提示:error C2371: “_user_level_map” : 重定义;不同的基类型
    很纳闷,为什么map <string,   enum   uLevel>   GlobalWrap::写到这个地方的时候,提示出map的成员函数(map是泛型算法中的),而不是GlobalWrap的成员函数
    Mackz 帮忙看看呢,谢谢了。
      

  4.   

    我使用的是.net 2003 编译的。
      

  5.   

    这是一小段代码。编译能通过,但是生成解决方案时有提示有9个无法解析的外部符号。最近在学OSG,可是这个小程序编译都通不过啊。#include <osgDB/ReadFile>
    #include <osgViewer/Viewer>void main()
    {
    osgViewer::Viewer ok;
    ok.setSceneData(osgDB::readNodeFile("cow.osg"));
    ok.realize();
    ok.run();
    }
      

  6.   

    map <string,  enum  uLevel>  GlobalWrap::_user_level_map; 在.CPP文件里面加
      

  7.   

    遇到同样的问题了  是在实现自己的vector的时候,allocator不能定义啊
      

  8.   

    static map< string, enum uLevel > _user_level_map;
    在h声明后,在cpp在定义下,map< string, enum uLevel > class::_userlevel_map;