LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-08-2005, 10:46 PM   #1
Kroenecker
Member
 
Registered: May 2003
Location: The States
Distribution: Gentoo
Posts: 245

Rep: Reputation: 30
Linked Lists and Queues


*********If my code below contains an error, you don't need to let me know. I just want
to know if I am on the right track*********

I have to do the following:

Make a linked list class (done for the most part).
Make a que class.

Right now inside the linked list class I have a stuct that contains the data and a pointer to the next node. I also have a pointer to a seperate Que class.

For the list:

struct ListNode
{
ListItemType name;
ListNode * forward;
ListNode * backward;
QueType * que;
};

class linkedList
{
public:
linkedList();
~linkedList();
void addLink(string);
void removeLink(string);
bool searchLink(string);
void compareLink(string);
bool isEmpty();
bool isFull();
void clearList();
private:
ListNode * circle;
};


For the Queue:

struct QueNode
{
ItemType data;
QueNode *link;
};

class Que
{
public:
Que();
Que(const Que &);
const Que &operator=(const Que &);
unsigned long lengthIs(void)const;
~Que();
void MakeEmpty();
bool IsEmpty()const;
bool IsFull()const;
void Enqueue(const ItemType &);
void Dequeue(ItemType &);
void debugPrint(std:stream &)const;
void removeLast(ItemType &);
void switchFirstLast(void);
private:
QueNode *first;
QueNode *last;
unsigned long length;
};

Now my question is can I access the public member functions of the Que class from within member functions of the Linked List class without using inheritance?

For instance: circle->que->MakeEmpty();

I guess I'm being a bit dumb about this. If this makes any sense, some pointers would be appreciated.
 
Old 04-08-2005, 10:49 PM   #2
Kroenecker
Member
 
Registered: May 2003
Location: The States
Distribution: Gentoo
Posts: 245

Original Poster
Rep: Reputation: 30
Nevermind:P I made a typo and have it all straightened out
 
Old 04-09-2005, 01:59 AM   #3
Siavash
LQ Newbie
 
Registered: Apr 2005
Posts: 5

Rep: Reputation: 0
Yes you ca naccess the public member functions of the Que class from within member functions of the Linked List class without using inheritance, but you should let the "LinkedList" know the "Que".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linked lists: java vs c kpachopoulos Programming 4 10-30-2005 04:41 PM
Linked Lists leonidg Programming 7 03-10-2005 02:07 AM
queue and linked lists Palamides Programming 2 03-09-2005 08:08 PM
Linked Lists - What and Why? scuzzman Programming 9 12-31-2004 10:51 AM
c++ linked lists jclark00001 Programming 10 02-23-2003 02:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration