471,311 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,311 software developers and data experts.

circular link list in c++

69
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*'
Oct 20 '06
103 15604
saraSS
69
yes I have a sort funtion, and the a[i] was my way to move the pointer through the list but guess not working, how can I move the pointer through the list so I can use a for loop? I am passing the pointer to the list and is type listnodeptr and I cant get the numitem() in the listclass to go from 0 to numitem(),Or maybe a while the pointer is not NULL but how do I move through the list ?
Oct 30 '06 #101
arne
315 Expert 100+
yes I have a sort funtion, and the a[i] was my way to move the pointer through the list but guess not working, how can I move the pointer through the list so I can use a for loop? I am passing the pointer to the list and is type listnodeptr and I cant get the numitem() in the listclass to go from 0 to numitem(),Or maybe a while the pointer is not NULL but how do I move through the list ?
If you have a pointer to the first list element, you can just do something like
Expand|Select|Wrap|Line Numbers
  1. int counter = 0;
  2. listnodeptr current = ... ;  // let current point to the first node, should be                  
  3.                                      // like something like current = List->first; or similar 
  4. while( counter < numitem() ) {
  5.  
  6.              // work with current->Info as the current node's content
  7.  
  8.              current = current->next;
  9.              ++counter;
  10. }
  11.  
If the list was not circular, you could use while( current != NULL ) as the condition.
Oct 30 '06 #102
saraSS
69
yes but numitem()is in my class function and I can get to it without the list
Oct 30 '06 #103
saraSS
69
pointer are not working ok i'm trying to pass the pointers to two of my circular lists and trying to make just one list with no repearing element but keep getting errors
this is my function
ListNodePtr list_union(ListNodePtr &a,ListNodePtr &b)
{
int num;
ListNodePtr c;
ListNodePtr currenta = a;
ListNodePtr currentb = b;
ListClass newlist;
int k=0;
bool e;
int i=0;
int j=0;

while(currenta.Next!=a.Front)
{
e=true;
while(currentb->Next!=b->Front)
{
if(currenta->Info==currentb->Info)
newlist.InsertRear(currenta->Info);
else
newlist.InsertRear(currenta->Info);
}
}
cout<<newlist.NumItems()<<" ";
newlist.printing();
cout<<endl;

return c;
}

and getting errors like
-bash-2.05b$ g++ mycirlist.cpp
mycirlist.cpp: In function `ListNodeClass* list_union(ListNodeClass*&,
ListNodeClass*&)':
mycirlist.cpp:259: request for member `Next' in `currenta', which is of
non-aggregate type `ListNodeClass*'
mycirlist.cpp:259: request for member `Front' in `a', which is of non-aggregate
type `ListNodeClass*'
mycirlist.cpp:15: `ListNodeClass*ListNodeClass::Next' is private
mycirlist.cpp:262: within this context
mycirlist.cpp:262: `class ListNodeClass' has no member named `Front'
mycirlist.cpp:14: `ItemType ListNodeClass::Info' is private
mycirlist.cpp:264: within this context
mycirlist.cpp:14: `ItemType ListNodeClass::Info' is private
mycirlist.cpp:264: within this context
mycirlist.cpp:14: `ItemType ListNodeClass::Info' is private
mycirlist.cpp:265: within this context
mycirlist.cpp:14: `ItemType ListNodeClass::Info' is private
mycirlist.cpp:267: within this context
why and how can i fix it?
Oct 31 '06 #104

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by barias | last post: by
3 posts views Thread by Giampaolo Rodola' | last post: by
2 posts views Thread by morris11 | last post: by
5 posts views Thread by =?Utf-8?B?Qm9i?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.