【发布时间】:2015-10-21 13:05:45
【问题描述】:
我正在编写使用自定义链表类的代码。列表类有如下功能:
void linkedList::expire(Interval *interval, int64 currentDt)
{
node *t = head, *d;
while ( t != NULL )
{
if ( t->addedDt < currentDt - ( interval->time + (((long long int)interval->month)*30*24*3600*1000000) ) )
{
// this node is older than the expiration and must be deleted
d = t;
t = t->next;
if ( head == d )
head = t;
if ( current == d )
current = t;
if ( tail == d )
tail = NULL;
nodes--;
//printf("Expired %d: %s\n", d->key, d->value);
delete d;
}
else
{
t = t->next;
}
}
}
我不明白的是函数中的第一行代码:
node *t = head, *d;
这段代码是如何编译的?如何将两个值分配给单个变量,或者这是一些速记快捷方式? head 是 *node 类型的成员变量,但在其他任何地方都找不到 d。
【问题讨论】:
标签: c++ pointers variable-assignment