自定义的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的实现方法示例详解
下面是`Node`的定义:```gotype Node struct { Value interface{} next, prev *Node}```接着,定义链表(List)结构体。
访问链表的第index数据
truct Node{int data;Node*next;};struct LinkedList{Node*head;int size;};//返回指定下标节点的数据引用,目的是按下标访问节点数据/
kernel list
例如:```cstruct my_data { int data; struct list_head list;};void add_to_list(struct my_data *data, struct
C++ 使用模板实现一个List的实例
```cpptemplate <class T>class List {private: struct Node { T data; Node* next; }; // ...}
test_for_list.rar_linux 链表
例如:```ctypedef struct Node { int data; // 数据域,这里假设是整型数据 struct Node* next; // 指针域,指向下一个节点} Node;```此外


