读书人

求教商品目Goods在链接超市类mark的析

发布时间: 2013-10-25 14:36:53 作者: rapoo

求教商品类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'

读书人网 >C++

热点推荐