this 指针

在每个成员函数中, 标识符this 就是指向用户调用成员函数所用对象的指针。 c++提供了更简单的语法,当我们访问当前对象的成员时,无需再写this。成员函数中无法修改this。

Link* Link::inser(Link* n)
{
	Link* p = this;
	if(n == 0) return p;
	if(p == 0) return n;
	n->succ = p;
	if(p->prev) p->prev->succ = n;
	n->prev = p->prev;
	p->prev = n;
	return n;
}
Link* Link::inser(Link* n)
{
	if(n == 0) return this;
	if(this == 0) return n;
	n->succ = this;
	if(prev) prev->succ = n;
	n->prev = prev;
	prev = n;
	return n;
}

posted @ 2011-09-08 16:07  jc24  Views(200)  Comments(1)    收藏  举报