自定义的node struct list访问出错
#include "stdafx.h"
#include <list>
using namespace std;
struct node
{
int a;
void* ptr;
}T_Node;
typedef list<node *> T_MYLIST;
int _tmain(int argc, _TCHAR* argv[])
{
T_MYLIST mylist;
node *pNode = new node;
mylist.push_back(pNode);
T_MYLIST::iterator it = mylist.begin();
int num = it->a;
return 0;
}
报错如下
error C2839: 重载的“operator ->”的无效返回类型“node **”
error C2039: “a”: 不是“std::list<_Ty>::_Iterator<_Secure_validation>”的成员
#include <list>
using namespace std;
struct node
{
int a;
void* ptr;
}T_Node;
typedef list<node *> T_MYLIST;
int _tmain(int argc, _TCHAR* argv[])
{
T_MYLIST mylist;
node *pNode = new node;
mylist.push_back(pNode);
T_MYLIST::iterator it = mylist.begin();
int num = it->a;
return 0;
}
报错如下
error C2839: 重载的“operator ->”的无效返回类型“node **”
error C2039: “a”: 不是“std::list<_Ty>::_Iterator<_Secure_validation>”的成员
...全文
相关推荐
Golang中List的实现方法示例详解
最近决定复习下Go,所以下面这篇文章主要给大家介绍了关于Golang中List的实现方式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。
访问链表的第index数据
truct Node{ int data; Node*next; }; struct LinkedList{ Node*head; int size; }; //返回指定下标节点的数据引用,目的是按下标访问节点数据 //如果下标不在[0,size-1]范围,引发index异常 //此函数调用可为左只 int &elemAt(const LinkedList&list,const int index){ if(index=list.size)throw index; Node*p=list.head; for(int i=0;inext;} return p->data; }
kernel list
提取部分内核链表,方便在今后的任何项目中直接使用链表
C++ 使用模板实现一个List的实例
主要介绍了 C++ 使用模板实现一个List的实例的相关资料,需要的朋友可以参考下
test_for_list.rar_linux 链表
链表操作,试验版链表操作,试验版链表操作,试验版链表操作,试验版链表操作,试验版链表操作,试验版


