LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 08-03-2003, 10:48 PM   #1
chens_83
Member
 
Registered: Dec 2001
Location: Adelaide , South Australia
Distribution: redhat 7.2, Debian , OpenBSD
Posts: 123

Rep: Reputation: 15
C++ linked list fun


I am making some linked lists for a program at Uni

Ok check this function signature

Code:
 Node *list_dump(Node const *const& x)
The function is supposed
-to display the address of the next node.
-Value of the Node
-Value of the next field.

WTF!!!11?@@

ok can someone PLS decipher the signature so i can figure out what its doing. Im alright when it comes to simple pointers/references but this is bit weird.

Last edited by chens_83; 08-04-2003 at 07:38 AM.
 
Old 08-04-2003, 04:19 AM   #2
DIYLinux
Member
 
Registered: Jul 2003
Location: NL
Distribution: My own
Posts: 92

Rep: Reputation: 18
Without looking at the function definition, I can safely say it should probably be rewritten.

The function takes a constant pointer to a constant reference to a Node, and returns nothing, so it relies on side effects.

Looks like it was written by someone who doesnt really understand C++. References are just constant pointers that you dont have to dereference manually.

Personally, i would limit my self to Node*'s to implement lists, and never mix references in. The this whole low level implementation should be wrapped. Perhaps it is even better not to bother at all, and use STL.

By the way, check this page on C declarations: http://occs.cs.oberlin.edu/~ajdavis/...1/Default.html
 
Old 08-04-2003, 07:40 AM   #3
chens_83
Member
 
Registered: Dec 2001
Location: Adelaide , South Australia
Distribution: redhat 7.2, Debian , OpenBSD
Posts: 123

Original Poster
Rep: Reputation: 15
Sorry i submitted the wrong function declaration. It does return a Node pointer.

THe programmer who did code does know what he is doing its just in the material to confuse us.
 
  


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
Recursion using linked-list of structures SeniorSE Programming 6 09-21-2005 02:40 AM
C++ Linked List question lowpro2k3 Programming 3 06-16-2005 10:15 AM
linked list + c dilberim82 Programming 5 05-04-2005 11:48 PM
cirular linked list pantera Programming 8 04-21-2005 06:59 AM
book linked list in C jetfreggel Programming 14 03-16-2003 10:52 AM

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

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