DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Linked List & Objects (http://www.daniweb.com/forums/thread35974.html)

TimC Nov 27th, 2005 4:38 pm
Linked List & Objects
 
Are there any good tutorials out there that explain adding objects to a single linked list. All I have come across are linked lists involving "structs". regards T

perniciosus Nov 28th, 2005 9:03 am
Re: Linked List & Objects
 
Well as now one answered this ill just add the comment I had in mind when I first saw the post... in c++ structs are just classes with default access right of public, as opposed to private, so any code that can handle structs can handle objects...

however if this was a question about an object oriented solution to the linked list problem I guess that does not help much ? if you are new to c++ perhaps the list of the stl can be of intrest.
Quote:

Originally Posted by Dinkum C++ on list
The template class describes an object that controls a varying-length sequence of elements of type Ty. The sequence is stored as a bidirectional linked list of elements, each containing a member of type Ty.


Lerner Nov 28th, 2005 11:19 am
Re: Linked List & Objects
 
I find it useful to think of a list as a sequence of objects, frequently called links or nodes, linked by pointers. The link/nodes can be instances of a struct/class which in turn contain both a data object and at least one pointer. In C you can only use structs to do this, as the concept of class isn't available. In C++ a struct and a class are the same thing, except that struct members default to public access and class members default to public.

SpS Nov 28th, 2005 1:38 pm
Re: Linked List & Objects
 
Try This
http://www.cprogramming.com/tutorial/stl/stllist.html


All times are GMT -4. The time now is 5:46 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC