📄 node.cpp
字号:
#include "node.h"
int Node::count=0;
int Node::readi() const//成员函数readi的定义
{
return idata;
}
char Node::readc() const
{
return cdata;
}
Node * Node::readp() const
{
return prior;
}
Node * Node::readn() const
{
return next;
}
bool Node::set(int i)//重载成员函数定义
{
idata=i;
return true;
}
bool Node::set(char c)
{
cdata=c;
return true;
}
bool Node::setp(Node *p)
{
prior=p;
return true;
}
bool Node::setn(Node *n)
{
next=n;
return true;
}
Node::Node()//构造函数的定义
{
cout <<"Node constructor is running..." <<endl;//提示构造函数运行
count++;
idata=0;//初始化idata
cdata='0';//初始化cdata
prior=NULL;//初始化前驱结点指针
next=NULL;//初始化后续结点指针
}
Node::Node(int i,char c)//构造函数重载1
{
cout <<"Node constructor is running..." <<endl;
count++;
idata=i;
cdata=c;
prior=NULL;
next=NULL;
}
Node::Node(int i,char c,Node *p,Node *n)//构造函数重载2
{
cout <<"Node constructor is running..." <<endl;
count++;
idata=i;
cdata=c;
prior=p;
next=n;
}
Node::Node(Node &n)
{
count++;
idata=n.idata;
cdata=n.cdata;
prior=n.prior;
next=n.next;
}
Node::~Node()
{
count--;
cout <<"Node destructor is running..." <<endl;
}
int Node::allocation()
{
return count;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -