车险网上报价 海口:C++里编写时'head' used without having been initialized 是怎么回事 请指教

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 23:23:26
struct goods *input(struct goods *xyx)
{int w;
struct goods *p0,*p1,*p2;
struct goods *head;
p1=head;
E:\ 仓库管理\主函数.cpp(70) : warning C4700: local variable 'head' used without having been initialized

void main()
{ int x;
mode p1("xyx");
screen p2;
struct goods *xyx;
struct goods *head;
E:\ 仓库管理\主函数.cpp(110) : warning C4101: 'head' : unreferenced local variable

就是说你的那个head指针变量还没初始化就给其他的指针赋值,这样的话,编译器就会报warning.你可以在申请head的时候这样写:struct goods *head = new goods;给它一个初值就好了.

warning C4700: local variable 'head' used without having been initialized
这个二楼说的对。

warning C4101: 'head' : unreferenced local variable
是说,你定义了 head 却没有使用它。

头文件没添加