首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

aCC编译有关问题

2012-02-27 
aCC编译问题void*pResultNULLfor(POSITIONpositionm_tree.GetRootPosition()position!NULLm_tree.Ge

aCC编译问题
void*   pResult     =     NULL;
for(POSITION   position     =     m_tree.GetRootPosition();
position     !=   NULL;
m_tree.GetNext(position)
)
{
pResult     =     m_tree.GetAt(position);
if   (pResult)   {
delete   pResult;
pResult     =     NULL;
}
}
用aCC编译时出现下列问题:
An   object   cannot   be   deleted   using   a   pointer   of   type
        'void   * '   since   the   type   of   the   object   allocated   is   unknown.   Either   delete   the   object   using   the   allocated
        type   or   call   operator   delete   directly.
                                                        delete   pResult;
而用g++编译时不会有次问题出现,请问是什么原因,如何解决!谢谢!
                                                                      ^^^^^^^

[解决办法]
在这个问题上,显然aCC更好,如果result不是对象,你可以用free(result)来释放内存.

[解决办法]
第一个是因为类型未知,不能直接delete

aCC也有让人不习惯的地方,比如将char *s= "s ";的 "s "当作string类来存储

[解决办法]
还有它的库里边namespace std是不存在的

热点排行