Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Feb 15th, 2008, 11:19 PM   #1
jason999x
Newbie
 
Join Date: Feb 2008
Posts: 6
Rep Power: 0 jason999x is on a distinguished road
one class to implement a linked list of objects of another class

say you're managing a stock portfolio... of class Portfolio, and it is to contain a linked list of several of class Stock... or more like... Portfolio is supposed to contain a Node structure to contain each Stock and the pointer to the head list... is this how it is done?

c++ Syntax (Toggle Plain Text)
  1. class Portfolio
  2. {
  3. struct Node
  4. {
  5. Stock whateverstock;
  6. Stock* head;
  7. }
  8. }

Does this node actually contain a full Stock object instance? Or does a node within the Portfolio class only contain the pointer? There was some template for doing things like this... but I forget how that's done... let me attempt a more generic example...

c++ Syntax (Toggle Plain Text)
  1. class Whatever
  2. {
  3. struct Node
  4. {
  5. SomeOtherObject thatObject;
  6. SomeOtherObject* headptr;
  7. }
  8. }

Note that NO inheritance is used here. Portfolio does not inherit anything from Stock or vice versa.
jason999x is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
linked list problems bl00dninja C++ 6 Feb 17th, 2008 10:30 AM
Linked List Of Objects Ade C++ 10 May 14th, 2007 10:25 AM
singly-linked list templaste class in C++ w/ example driver bl00dninja Show Off Your Open Source Projects 0 Sep 11th, 2006 1:05 AM
Singly Linked List Help Firebar Java 3 May 22nd, 2005 10:56 AM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:20 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC