error C2227: left of '->first' must point to class/struct/union

今天调试程序时,遇到这么一个错误:

error C2227: left of ‘->first‘ must point to class/struct/union

#include<iostream>
using namespace std;
#define ElemType int

struct node
{
	struct node *first;
	struct node *last;
	int size;
};
typedef struct node Node;
typedef struct node *PNode;
typedef PNode List;

void Initlist(List *list)
{
	*list->first = *list->last = (node *)malloc(sizeof(node));
	*list->size = 0;
}

int main()
{
	List mylist;
	Initlist(&mylist);
	return 0;
}

错误如下:

到底哪出错了呢?????

原来:->优先级(高于)*

*list->last ===>>>>>*(list->last),*list是指向结构体的指针,而list不是,,现在知道错误的原因所在了吧!!!注意哦!!

将*list->last -------改为-------->>>(*list)->last,问题就解决了

error C2227: left of '->first' must point to class/struct/union

时间: 2024-08-25 21:10:13

error C2227: left of '->first' must point to class/struct/union的相关文章

windows下尝试编写node模块

1,首先参考http://www.cnblogs.com/yupeng/p/3469444.html写了一个模块 2,按照指引运行 F:\Program Files\nodejs\mymodule>node-gyp configure build 奶奶的,一开始就少了一个node-gyp,上网一艘,原来这也是一个模块 'node-gyp' 不是内部或外部命令,也不是可运行的程序或批处理文件. F:\Program Files\nodejs\mymodule>npm install -g nod

cocos2d-x 头文件中添加方法变量导致编译报错

代码如下: HelloWorldScene.h #ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__ #include "cocos2d.h"class HelloWorld : public cocos2d::Layer{public:    // there's no 'id' in cpp, so we recommend returning the class instance pointer    stati

cocos2dx触摸响应

Layer其实继承了触控的接口. 所以只需要重写一些函数即可. 在helloword类中重写: virtual bool init(); /** Callback function for touch began. * * @param touch Touch information. * @param unused_event Event information. * @return if return false, onTouchMoved, onTouchEnded, onTouchCan

Tag vs. Type Names

Tag vs. Type Names C treats tags as second class types. C++ isn't much kinder. Here's how to give them first-class treatment in both languages. Identifiers are among the most basic elements of programming languages. Languages use them to name entitie

C++工程编译之“error LNK2001: 无法解析的外部符号”

今天一整天都在折腾“error LNK2001: 无法解析的外部符号”,就在头疼不已的时候,总算是找到问题原因了:各个动态链接库的编译方式必须统一才行,要不然很容易对库函数的引用产生冲突.简单来说就是,如果使用的第三方函数库编译方式采用/MD,那么主工程也应该使用/MD.我使用了libevent,而主工程默认采用/MT,所以需要忽略一大堆的函数库,我还纳闷呢,怎么会这么奇怪!!今天总算是解决了长久以来的困惑了. 下面引用一篇文章的描述:[Z]VC运行库版本不同导致链接.LIB静态库时发生重复定义

【转】使用IAR时遇到的一些Error、Waring

http://hi.baidu.com/sendoc/blog 作为菜虫,在使用IAR的时候编写CC2430..Z-Stack2006程序会遇到如下一些错误,当然随着学习的深入,我会持续更新. 1 Q: Error[e16]: Segment XDATA_Z (size: 0x19a1 align: 0) is too long for segment definition. At least 0xe4c more bytes needed. The problem occurred while

VC++ : error LNK2005: ... already defined in *.obj

今天写代码遇到了这么一个链接错误:"已经在*.obj中定义". error LNK2005: "void __cdecl ReplaceWstringVar(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::map<class std::basic_string<w

突然出现错误gdiplustypes.h(280): error C2059: syntax error : &#39;constant&#39;等未知错误

gdiplustypes.h(280): error C2059: syntax error : 'constant'gdiplustypes.h(280): error C2238: unexpected token(s) preceding ';'gdiplustypes.h(281): error C2059: syntax error : 'constant'gdiplustypes.h(281): error C2238: unexpected token(s) preceding '

Cocos2DX开发:记录遇到的一些问题和解决方法

今天看了一下以前学习cocos2dx时记录的一些笔记,主要是在实际中遇到的一些问题,整理了一下,就成为了这篇文章,便于自己以后查找,也为一些新手提供点经验. 这篇文章会一直更新,将自己之后开发中遇到的问题也更新到文章中. 1.使用cocos2d-x-2.2.0新建项目的过程 解决:2.0以后的版本没有了install-templates-msvc.bat配置模板脚本,不能直接在VS2010中直接创建cocos2d-x项目,只能通过 终端窗口运行Python脚本来新建项目. 方案: 步骤1:将终端