473,854 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

circular link list in c++

69 New Member
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_Sta ck *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_St ack*'
newcir.cpp:110: request for member `print_list' in `obj[i]', which is of
non-aggregate type `Linked_list_St ack*'
Oct 20 '06
103 16033
saraSS
69 New Member
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 Recognized Expert Contributor
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 New Member
yes but numitem()is in my class function and I can get to it without the list
Oct 30 '06 #103
saraSS
69 New Member
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(List NodePtr &a,ListNodeP tr &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==curren tb->Info)
newlist.InsertR ear(currenta->Info);
else
newlist.InsertR ear(currenta->Info);
}
}
cout<<newlist.N umItems()<<" ";
newlist.printin g();
cout<<endl;

return c;
}

and getting errors like
-bash-2.05b$ g++ mycirlist.cpp
mycirlist.cpp: In function `ListNodeClass* list_union(List NodeClass*&,
ListNodeClass*& )':
mycirlist.cpp:2 59: request for member `Next' in `currenta', which is of
non-aggregate type `ListNodeClass* '
mycirlist.cpp:2 59: request for member `Front' in `a', which is of non-aggregate
type `ListNodeClass* '
mycirlist.cpp:1 5: `ListNodeClass* ListNodeClass:: Next' is private
mycirlist.cpp:2 62: within this context
mycirlist.cpp:2 62: `class ListNodeClass' has no member named `Front'
mycirlist.cpp:1 4: `ItemType ListNodeClass:: Info' is private
mycirlist.cpp:2 64: within this context
mycirlist.cpp:1 4: `ItemType ListNodeClass:: Info' is private
mycirlist.cpp:2 64: within this context
mycirlist.cpp:1 4: `ItemType ListNodeClass:: Info' is private
mycirlist.cpp:2 65: within this context
mycirlist.cpp:1 4: `ItemType ListNodeClass:: Info' is private
mycirlist.cpp:2 67: within this context
why and how can i fix it?
Oct 31 '06 #104

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

Similar topics

1
12852
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
7
13531
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time dependencies). But then I started wondering how "easy" it would be to similarly make a NON-RUNTIME circular dependency between (implicitly linked) DLLs. Indeed authors like John Lakos, who focus on compile/link-time dependencies (not run-time),...
3
7064
by: donnyma | last post by:
I have a problem that looks like it has not been discussed before in these groups. I have a simple SQLAgent job that runs sp_who (could be anything, but let's just say sp_who for this example). I have set the jobstep to write to an output file "T:\out.txt". If the job is owned by an admin, it runs fine and writes the output file. If it is owned by a non-admin user, it gets the following error msg: Warning: cannot write logfile...
12
15714
by: shivapadma | last post by:
please anyone tell me whether the following code works for checking the linked list is circular or not? address 0 address1 address2 | A|address1| |B|address2| |C|address0| | | | | ptr1 ptr2 A,B,C-are elements in list.
3
4146
by: Giampaolo Rodola' | last post by:
Hi there, I would like to know if such function would be correct for verifying if a link is broken and/or circular. def isvalidlink(path): assert os.path.islink(path) try: os.stat(path) except os.error: return 1
2
6434
by: morris11 | last post by:
I am trying to create a circular list that includes insert() , find() and remove() methodes. also a step() method that moves current along to the next link. I still need to display the list by breaking the circle at some arbitrary point to print it on the screen. Does anyone have an idea how to do that? import javax.swing.JOptionPane; public class CLL { public class Link { int item=0; Link next;
5
3405
by: =?Utf-8?B?Qm9i?= | last post by:
I have a table of dependencies and want to check to see if the dependencies cause a circular reference. Any sugesstions on how to do this using c#. Example, ID DependsOnID 1 2 1 4 2 3 3 1 (circular reference)
0
2838
balabaster
by: balabaster | last post by:
Hi, I have a couple of tables: Units( Unit_PKey Int Identity(1,1) Primary Key, Unit_Name nvarchar(8), Unit_Description nvarchar(32) )
5
1429
by: Muzammil | last post by:
i have problem with this operator "+" in doubly circular link list.(i think i have problem with return type). error is of instantiate error.(mean type dismatch) if any one can help me please reply. template <class T> DoublyCircularLinkList<TDoublyCircularLinkList<T>:: operator + (const DoublyCircularLinkList& rhs) { if (head==0 && rhs.head==0) {
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9526
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7084
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4567
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4168
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.