c ++中的循环链接列表 [英] circular link list in c++

查看:54
本文介绍了c ++中的循环链接列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建和循环链接列表数组但是当我读取输入文件时,我只是获取一个长链接列表而不是不同的列表并且在尝试使用Linked_list_Stack * obj [arraysize];我收到这个错误

newcir.cpp:107:请求'obj [i]''中的成员`push'',这是

非聚合类型`Linked_list_Stack *''

newcir.cpp:110:在`obj [i]''中请求成员`print_list'',这是

非聚合类型`Linked_list_Stack *''

I''m trying to built and array of circular link list but when I read the input file Ijust get a long link list instead of different list and after trying to use Linked_list_Stack *obj[arraysize]; I''m getting this errors
newcir.cpp:107: request for member `push'' in `obj[i]'', which is of
non-aggregate type `Linked_list_Stack*''
newcir.cpp:110: request for member `print_list'' in `obj[i]'', which is of
non-aggregate type `Linked_list_Stack*''

推荐答案


我正在尝试构建和循环链接列表数组但是当我读取输入文件时,Ijust得到一个长链接列表而不是不同的列表,并在尝试使用Linked_list_Stack * obj [arraysize];我收到这个错误

newcir.cpp:107:请求'obj [i]''中的成员`push'',这是

非聚合类型`Linked_list_Stack *''

newcir.cpp:110:在`obj [i]''中请求成员`print_list'',这是

非聚合类型`Linked_list_Stack *''
I''m trying to built and array of circular link list but when I read the input file Ijust get a long link list instead of different list and after trying to use Linked_list_Stack *obj[arraysize]; I''m getting this errors
newcir.cpp:107: request for member `push'' in `obj[i]'', which is of
non-aggregate type `Linked_list_Stack*''
newcir.cpp:110: request for member `print_list'' in `obj[i]'', which is of
non-aggregate type `Linked_list_Stack*''



可能是您尝试使用类似

May it be that you try to access the push member with code like

展开 | 选择 | Wrap | 行号


修复那个问题,但仍然只得到一个列表我需要di传单列表我的主要是

int main()

{

int i;

cin>> arraysize ;

Linked_list_Stack * obj [arraysize];


for(i = 0; i< arraysize; i ++)

{

obj [i] = new Linked_list_Stack;

while(!cin.eof())

{

cin> ;> num;

if(num!= - 1)

{

obj [i] - > push(); < br b> b $ b $

obj [i] - > print_list();

cout<< endl;

}

返回0;
fix that problem thatnks but still getting only one list I need different list my main is
int main( )
{
int i;
cin>>arraysize;
Linked_list_Stack *obj[arraysize];

for(i=0;i<arraysize;i++)
{
obj[i] = new Linked_list_Stack;
while(!cin.eof())
{
cin>>num;
if(num!=-1)
{
obj[i]->push( );
}
}
obj[i]->print_list( );
cout<<endl;
}
return 0;


你能详细解释一下你想做什么吗?

据我所知,从你的代码来看,你是
- 构建一个指向Linked_list_Stack类型元素的指针数组


- 为数组中的每个指针分配对象


- 调用这些对象的成员函数push()(推送到什么地方btw?) />

- 最后你调用了成员函数print_list(这里将要/应该打印什么?)


你能解释一下如果你发生了什么吗? '程序是否正常工作?
Could you please explain a little bit more in detail what you''re trying to do?
As far as I understand from your code, you''re

- building an array of pointers to elements of type Linked_list_Stack

- allocating objects for each of the pointers in the array

- invoking the member function push() of these objects (what is pushed here btw?)

- and finally you invoke the member function print_list (what will/should be printed here?)

Could you explain what should happen if you''re program worked correctly?


这篇关于c ++中的循环链接列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆