LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-24-2004, 06:13 PM   #1
leroy27336
Member
 
Registered: Nov 2003
Distribution: LTS Ubuntu 6.06
Posts: 127

Rep: Reputation: 15
node class help...


class node
{
public:
typedef int value_type;

node (value_type the_data = value_type(), node *link_field = NULL) {data = the_data; link = link_field;}

void set_link (node* link_field) {link = link_field;}
void set_data (value_type value) {data = value;}
value_type get_data () const {return data;}
node *get_link () const {return link;}

private:
value_type data;
node *link;
};

void create_list(node *& head_par, node::value_type value);

i have a class and a non member function that looks like the above example.....

the create_list function is suppose to put integer numbers into a linked list. can someone please help writing the function definition in order for me to do this...the value is coming from the main part of the program. thanks for any help anyone can give me.
 
Old 02-25-2004, 01:35 PM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
I'm not too clear on what create_list() is supposed to do... it looks like it's only receiving two arguments - a pointer to part of the list (the head, I suppose?) and a single value_type (integer). How can it create a list with only one integer? Or does the main program call it multiple times with different values? Does head_par always point to the first node in the list?

I guess your create_list function will have to create a new node, insert it at the end (?) of the list, and then set its value to whatever was passed into create_list. Just guessing here, since I am not too sure what you're trying to do
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Implementing a vector class from a list class purefan Programming 9 04-14-2005 10:48 PM
c++ list class, type of node? exodist Programming 2 05-20-2004 06:27 PM
BlackBox.class & VerifierBug.class virus ??? dalek Linux - Security 4 02-29-2004 08:55 AM
Inheriting class members (Qt C++, QApplication class) jtshaw Programming 2 01-15-2004 11:52 AM
c++ : regarding (inheritence)base class and derived class edreddy Programming 6 07-31-2002 06:33 PM

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

All times are GMT -5. The time now is 07:57 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