有关gcc的问题
日期:2007-02-12 荐:
有关gcc的问题class CGlobalConfigInfo : public CNoncopyable{public:CGlobalConfigInfo(vector<CConnectionInfo*>* pvcConnInfo, map<string, char*>* pmapCode2Name, char* pcRootPath, char* pcTempRootPath,char* pcBkRootPath,int nSpan, char* pcFixedTime, int nMaxRcdPerFile, char* pRunningMode);virtual ~CGlobalConfigInfo();int GetMaxRcdPerFile() const{return m_nMaxRcdPerFile;}int GetSpan() const{return m_nSpan;}char* GetFixedTime() const{return m_pcFixedTime;}char* GetRootPath() const{return m_pcRootPath;}map<string, char*>* GetCode2Name() const{return this->m_pmapCode2Name;}char* GetRunningMode() const{return m_pRunningMode;}vector<CConnectionInfo*>* GetConnInfo() const{return m_pvctConnInfo;}char* GetBkRootPath() const{return m_pcBkRootPath;}char* GetTempRootPath() const{return m_pcTempRootPath;}private:CGlobalConfigInfo();vector<CConnectionInfo*>* m_pvctConnInfo;map<string, char*>* m_pmapCode2Name;char* m_pcRootPath;int m_nSpan;char* m_pcFixedTime;int m_nMaxRcdPerFile;char* m_pRunningMode;char* m_pcTempRootPath;char* m_pcBkRootPath;};CGlobalConfigInfo::CGlobalConfigInfo(vector<CConnectionInfo*>* pvcConnInfo, map<string, char*>* pmapCode2Name, char* pcRootPath, char* pcTempRootPath,char* pcBkRootPath,int nSpan, char* pcFixedTime, int nMaxRcdPerFile, char* pRunningMode) :m_nSpan(nSpan),m_nMaxRcdPerFile(nMaxRcdPerFile),m_pcRootPath(pcRootPath), m_pcTempRootPath(pcTempRootPath),m_pcBkRootPath(pcBkRootPath),m_pcFixedTime(pcFixedTime), m_pvctConnInfo(pvcConnInfo),m_pmapCode2Name(pmapCode2Name),m_pRunningMode(pRunningMode){(这里有警告:when initialized here)}CGlobalConfigInfo::~CGlobalConfigInfo(){delete this->m_pcRootPath;delete this->m_pcTempRootPath;delete this->m_pcBkRootPath;delete this->m_pcFixedTime;delete this->m_pvctConnInfo;//delete static_cast<void*> (this->m_pmapCode2Name);delete this->m_pmapCode2Name;(这里编译出错)delete this->m_pRunningMode;}用vc7没有问题,用g 编译出错;错误信息为when initialized hereinstantiated from `void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_erase(std::_Rb_tree_node<_Val>*) [with _Key = std::string, _Val = std::pair<const std::string, char*>, _KeyOfValue = std::_Select1st<std::pair<const std::string, char*> >, _Compare = std::less<std::string>, _Alloc = std::allocator<std::pair<const std::string, char*> >]'[/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c /3.4.2/bits/stl_tree.h]instantiated from `std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::~_Rb_tree() [with _Key = std::string, _Val = std::pair<const std::string, char*>, _KeyOfValue = std::_Select1st<std::pair<const std::string, char*> >, _Compare = std::less<std::string>, _Alloc = std::allocator<std::pair<const std::string, char*> >]'[/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c /3.4.2/bits/stl_tree.h]instantiated from `std::_Rb_tree_node<std::pair<const std::string, char*> >'[/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c /3.4.2/bits/stl_tree.h]error: `std::pair<_T1, _T2>::first' has incomplete type[/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c /3.4.2/bits/stl_pair.h]error: declaration of `const struct std::string'[/usr/lib/gcc/i386-redhat-linux/3.4.2/../../../../include/c /3.4.2/bits/stringfwd.h]这个类主要做的就是根据构造函数传入的参数初试化成员变量,析构的时候释放内存,为什么delete map的时候就会编译出错呢?帖子比较长,还望大家耐心看完,十分感谢!!!不好意思,自己顶了。你std::pair<_T1, _T2>::first 没有完全初始化这是库的内部实现方法造成的那应该如何处理?我这里只是一个指针,为什么还要对map里的东西初试化?没人知道吗?再顶。不懂.帮顶一下.还是没有人知道吗?顶顶看。这么长的东东,看都要半天帮顶了
标签: