473,889 Members | 1,803 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 16044
saraSS
69 New Member
the assignment say yes and I need to name every list with and alphabet letter so I can do the operatinons later
Oct 21 '06 #21
saraSS
69 New Member
Each set is to be stored as an ordered, singly-linked,
circular list with a header.
Oct 21 '06 #22
arne
315 Recognized Expert Contributor
Each set is to be stored as an ordered, singly-linked,
circular list with a header.
Is that a hint or a demand? Sounds a little like a demand ...

STL lists are neither singly-linked nor circular. And AFAIK the STL does not provide such lists, since they are not that common, I would guess.

That's why I said in the beginning that here is nothing wrong with implementing own containers, if you have a good reason for it. Non-existence is a good reason :-)

One could certainly mimic a circular list using the features of the STL list container ...
Oct 21 '06 #23
saraSS
69 New Member
so how can I mimic the circular list I work good with exemples lol
Oct 21 '06 #24
saraSS
69 New Member
remember my initial code I rewrite the whiel loop and is working so i'm gonna try to keep working with that one and using a few of the <list> funtions see if help me a lit
Oct 21 '06 #25
arne
315 Recognized Expert Contributor
so how can I mimic the circular list I work good with exemples lol
Hmm, ok. So what distinguishes a serial from circular list?

The successor of the last element is the first element.
Since you want a singly linked list, you don't have to care about the predecessor of the first element, there is only one direction.

In principal, you can either write a wrapper class which simply contains a std::list or you could derive a class from std::and "extend" its functionality.
A wrapper class may have the advantage that you could also "provide" (reduce) the functionality of single-linkedness ... :-)
Oct 21 '06 #26
saraSS
69 New Member
I but with the initial program I cant mix and match looks like I mean the funtion that I have and the functions from the library ;(
Oct 21 '06 #27
arne
315 Recognized Expert Contributor
I but with the initial program I cant mix and match looks like I mean the funtion that I have and the functions from the library ;(
It's a tradeoff. You have the choice between
- rewriting your program and writing a wrapper/derived class, and
- making your own circular list container work.

However:
Looking through your former posts, I would recommend that you clarify for yourself the requirements and decide _how_ you want to organize your data. (In the very beginning you talked about a stack, but currently we're at an array of singly-linked circular lists.)
This is the very first (design!) decision you have to take. After that you should think about which data structures are appropriate to implement your design. Otherwise we'll go in circles ...
Oct 21 '06 #28
saraSS
69 New Member
is not my decision actually is what the assigment says it says to implement a stack based postfix calculator for sets of integers and those sets need to be store as an ordered, singly-linked,circular list with a header, and I need to use some recycling list for the calculator.
but I though the array was gonna make it easy I guess i need to change the array for a stack of circular list? I dont know lol
Oct 21 '06 #29
arne
315 Recognized Expert Contributor
is not my decision actually is what the assigment says it says to implement a stack based postfix calculator for sets of integers and those sets need to be store as an ordered, singly-linked,circular list with a header, and I need to use some recycling list for the calculator.
but I though the array was gonna make it easy I guess i need to change the array for a stack of circular list? I dont know lol
No, you need both, an array and a stack:

I took the time to read through your assignment. I think what you need are the following "ingredient s"

- a node_struct (list element with value and successor pointer)
- a header_struct which points to a first node
- an array/vector of header structs, where you will store and keep the input
- a stack (maybe std::stack<head er_struct *>?), where you store the links to the cloned lists
- stack operations (push, pop)
- list operations (clone and all the set mathematics stuff as required by the assignment)

The array/vector is used as a reference when you have to put the same set onto the stack again. The stack itself is what you use for the math. That's why you need both, I would say.
Oct 21 '06 #30

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

Similar topics

1
12855
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
13533
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
7068
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
15718
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
4147
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
3406
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
1430
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11203
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...
1
10896
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10443
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
9612
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
7151
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
5830
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...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
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.