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

求教商品目Goods在链接超市类mark的析构函数delete p (Goods *)无法编译

2013-10-25 
求教商品类Goods在链接超市类mark的析构函数delete p (Goods *)无法编译mark::~mark(){Goods* Pwhile(hea

求教商品类Goods在链接超市类mark的析构函数delete p (Goods *)无法编译
mark::~mark()
{
Goods* P;
while(head!=NULL)
{
p=head;
head=head->next();
delete p;
}
}
error C2065: 'p' : undeclared identifier
f:\新建文件夹\xueguang\mark.cpp(14) : error C2440: '=' : cannot convert from 'class Goods *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\新建文件夹\xueguang\mark.cpp(15) : error C2248: 'next' : cannot access private member declared in class 'Goods'
        f:\新建文件夹\xueguang\goods.h(7) : see declaration of 'next'
f:\新建文件夹\xueguang\mark.cpp(15) : error C2064: term does not evaluate to a function
f:\新建文件夹\xueguang\mark.cpp(16) : error C2541: delete : cannot delete objects that are not pointers
执行 cl.exe 时出错.
[解决办法]
问题一大堆:
1.本来是P,却写了p,导致:error C2065: 'p' : undeclared identifier
                        error C2541: delete : cannot delete objects that are not pointers
执行 cl.exe 时出错.
                        error C2064: term does not evaluate to a function
2.访问next私有方法导致:error C2248: 'next' : cannot access private member declared in class 'Goods'
        f:\新建文件夹\xueguang\goods.h(7) : see declaration of 'next'

热点排行