C++ STL LIST错误!!!
//struct of data node
typedef struct DataNode{
unsigned char activated; //1: the dn available, 0 :not available
inttaskNum;
int tcpPort;
long dnSpace;
char dnAddr[16];
time_t activateTime;
list<BlockInfo> blkInfoList; //the blocks information which are stored in the DN
}DataNode;
typedef list<DataNode> DNLIST;
DNLIST::iterator dnodeit;
dnodeit = dnodeList.begin();
dnodeit->blkInfoList.push_back(blockinfo); //编译时该行出错
ack_upload.cpp: In function ‘void ack_upload(int)’:
ack_upload.cpp:184: error: no matching function for call to ‘std::list<BlockInfo, std::allocator<BlockInfo> >::push_back(ack_upload(int)::BlockInfo&)’
/usr/include/c++/4.4/bits/stl_list.h:919: note: candidates are: void std::list<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = BlockInfo, _Alloc = std::allocator<BlockInfo>]
哪位高手解答一下。谢谢。
[解决办法]
typedef list<DataNode> DNLIST;
DNLIST::iterator dnodeit;
dnodeit = dnodeList.begin();
这段代码有问题:没定义一个list<DataNode> 对象啊。。。 然后就去定义了一个 这个类型的 迭代器,这个里面也没元素,怎么访问?