c语言中定义完结构体后调用,在C++中,定义了结构体之后,怎么在函数中调用这些结构体?知道...

我自己做了个 结构体的插入链表 你看看

#include

using namespace std;

struct node

{

node *next;

int data;

};

class lianbiao:public node

{

public:

lianbiao()

{

head=new node[];

head->next=0;

head->data=0;

}

node *gethead()

{

return head;

}

void create_lianbiao(node *headnode);

void show(node *headnode);

void sethead(node *headnode)

{

head=headnode;

}

private:

node *head;

};

void lianbiao::create_lianbiao(node *headnode)

{

headnode=new node[];

headnode->data=0;

headnode->next=0;

sethead(headnode);

int dt;

cin>>dt;

while(dt!=2010)

{

node *hd=new node[];

hd->data=dt;

hd->next=NULL;

headnode->data=hd->data;

hd->next=headnode->next;

headnode->next=hd;

cin>>dt;

}

}

void lianbiao::show(node *headnode)

{

headnode=headnode->next;

while(headnode->next!=NULL)

{

cout<data<

headnode=headnode->next;

}

cout<data;

}

int main()

{

lianbiao lb;

lb.create_lianbiao(lb.gethead());

lb.show(lb.gethead());

return 0;

}

190a3684a07e14cd9eac554b720363a4.bmp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值