首页新闻找找看学习计划

vector指针赋值后地址错误

0
悬赏园豆:5 [待解决问题]

代码片段如下:

CopyConfigBase *copyConfig = CopyConfigManager::getInstance().get( pUser->copyid);
                            if ( !copyConfig) {
                                return true;
                            }   
                            Map* map = MapManager::getInstance().loadMap(copyConfig->mapid);
                            if ( !map ) { 
                                return true;
                            }   
                            RoleDefineVector* ndv = &(copyConfig->roleDefine);
                            //map->loadRole(copyConfig->roleDefine);
                            HangCopy* copy= new HangCopy( copyConfig, map);

 

调试结果如下:

(gdb) p copyConfig
$3 = (CopyConfigBase *) 0x1f17fe8
(gdb) p &(copyConfig->roleDefine)
$4 = (RoleDefineVector *) 0x1f18030
(gdb) n
299 Map* map = MapManager::getInstance().loadMap(copyConfig->mapid);
(gdb) n
300 if ( !map ) {
(gdb) n
303 RoleDefineVector* ndv = &(copyConfig->roleDefine);
(gdb) p &(copyConfig->roleDefine)
$5 = (RoleDefineVector *) 0x1f18030
(gdb) n
305 HangCopy* copy= new HangCopy( copyConfig, map);
(gdb) p ndv
$6 = (RoleDefineVector *) 0x1f1802c
(gdb) p *ndv
$7 = std::vector of length 38654705664, capacity 68719476736 = {Cannot access memory at address 0x1f1948000000000
(gdb) n
306 if ( copy ) {

 

为什么给ndv变量赋值后ndv的值为 0x1f1802c ,而不是 0x1f18030。copyConfig->roleDefine中的vector的值是正确。谢谢谁能解答下。

hi-keen的主页 hi-keen | 初学一级 | 园豆:197
提问于:2017-01-13 10:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册