473,836 Members | 2,210 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 16018
saraSS
69 New Member
yes every set needs to be a circular list
Oct 26 '06 #81
saraSS
69 New Member
the circular lists are working, to have a pointer for every one of them so I can make a copy of the list and evaluate some expression with the list in a postfix stack based way
Oct 27 '06 #82
saraSS
69 New Member
the pointer to the list are the ones not working I need some help with that
Oct 27 '06 #83
arne
315 Recognized Expert Contributor
the pointer to the list are the ones not working I need some help with that
Sure, if I can do it. Anything particular you have problems with?
Oct 27 '06 #84
saraSS
69 New Member
yes, I need to read the last line in my input file, and with that line if I have an "a" I need to make a copy of the first circular list and after that push it into the stack I have this fuction but not working think because i need a pointer or something

int main()
{
int i,m;
char postfix[80];
char listname = 97;

cin>>arraysize;
ListClass ListA[arraysize],L[arraysize];


for(i=0;i<array size;i++)
{
while(cin>>numb er && number!=-1)
{
ListA[i].InsertRear(num ber);
}
cout<<ListA[i].NumItems()<<" ";
ListA[i].printing();
cout<<endl;
}
Initialize ( );
cin.getline(pos tfix,80,'\n');
SetExpression (postfix);
cout <<postfix<< endl;
puts(postfix);
cout<<"ok";
strcpy(eval,pos tfix);
m=Evaluate( );
printf("answer: %d", m );
return 0;
}in main and function is

int Evaluate()
{
int i,l,A,B,Q,Z;
l=strlen(eval);

for(i=0;i<l;i++ )
{
if(eval[i])
{
Push(eval[i]);
}
else
{
A=Pop( );
B=Pop( );
switch(eval[i])
{
case 'U': break;
case 'I': break;
case '-': break;
case '\'' : break;
case '<' : break;
case '&' : break;
case '|' : break;
case '!' : break;
}
Push(Q);
}
}
Z=Pop( );

return Z;
}
Oct 27 '06 #85
arne
315 Recognized Expert Contributor
yes, I need to read the last line in my input file, and with that line if I have an "a" I need to make a copy of the first circular list and after that push it into the stack I have this fuction but not working think because i need a pointer or something
Hmm. As far as I understand, you don't need to make a copy of the list and push it on the stack. Just push pointers (or even symbols!) on the stack. Suppose the last line, i.e. the postfix expression, looks like

a b U

This means

push a on the stack
push b on the stack
unite, i.e. pop the top element from the stack, pop the top element from the stack (2 times!) and unite it.
push the result on the stack.

It is sufficient to push the symbol/pointer on the stack and to get the list content if you really need it, i.e. for the unite operation. Hence, for every operation you need a function which receives one or two symbols/pointers (the two symbols a and b in our example), fetches the list(s) contents from the array and performs the oeration. Afterwards the result has to be pushed on the stack. For this temporary result you need an additional list (and symbol/pointer!).

So, you don't have to push copies of the list on the stack, just pointers or symbols. This is much more efficient. Consider the example:

a a a a a a a ...

you would make several copies of the list a, but if you only use the pointer/symbol you save a lot of space and lose no information. You know what I mean?
Oct 28 '06 #86
saraSS
69 New Member
yes I know what you mean but I dont know how to do the pointer part I have tried some thing like
ListClass ListA[arraysize],*L; and this ListClass ListA[arraysize],*L[arraysize];

but nothing works pointing to every set is my problem
Oct 28 '06 #87
arne
315 Recognized Expert Contributor
yes I know what you mean but I dont know how to do the pointer part I have tried some thing like
ListClass ListA[arraysize],*L; and this ListClass ListA[arraysize],*L[arraysize];

but nothing works pointing to every set is my problem
I am not sure what you're trying to do here. The ListA is the array for the circular lists? What about the stack? Do you try to use the STL stack?

Can you explain that in more detail?
Oct 29 '06 #88
saraSS
69 New Member
I think I got the pointer part working but now looks like I'm not reading the last line of my input file (last line is the one with the expression)to do the evaluation

int main()
{
int i,m;
char postfix[80];
cin>>arraysize;
ListClass ListA[arraysize];


for(i=0;i<array size;i++)
{
while(cin>>numb er && number!=-1)
{
ListA[i].InsertRear(num ber);
}
cout<<ListA[i].NumItems()<<" ";
ListA[i].printing();
cout<<endl;
}
Initialize ( );
cin.getline(pos tfix,80);
cout<<postfix<< endl;
Evaluate(ListA, postfix);

return 0;
}

what I'm doing wrong think my while loop is using all the lines ?
idont know
Oct 29 '06 #89
arne
315 Recognized Expert Contributor
I think I got the pointer part working but now looks like I'm not reading the last line of my input file (last line is the one with the expression)to do the evaluation

int main()
{
int i,m;
char postfix[80];
cin>>arraysize;
ListClass ListA[arraysize];


for(i=0;i<array size;i++)
{
while(cin>>numb er && number!=-1)
{
ListA[i].InsertRear(num ber);
}
cout<<ListA[i].NumItems()<<" ";
ListA[i].printing();
cout<<endl;
}
Initialize ( );
cin.getline(pos tfix,80);
cout<<postfix<< endl;
Evaluate(ListA, postfix);

return 0;
}

what I'm doing wrong think my while loop is using all the lines ?
idont know
Looks ok to me .. what does the line
Expand|Select|Wrap|Line Numbers
  1. cout<<postfix<<endl;
  2.  
write to standard out?
Oct 29 '06 #90

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

Similar topics

1
12850
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
13529
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
7060
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
15709
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
3403
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
2831
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
9810
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
10527
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
10241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9358
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...
1
7773
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6973
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
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
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
4001
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.