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 Apr 5th, 2006, 9:39 AM   #1
Kry1010
Newbie
 
Join Date: Apr 2006
Location: UK
Posts: 3
Rep Power: 0 Kry1010 is on a distinguished road
Linking to a linked list within a linked list

Hello,

I'm having problems with linking to a linked list within a linked list. I'm using two different structs within my class 'Players';

	class Players
{
 private:
        struct playerRec
	{
		char name[25];
		int age;
		int goals;
		struct historyRec* historyPtr;
		struct playerRec* next;
	};

	struct playerRec startPtr;

	struct historyRec
	{
		char club[25];
		int dateJoined;
		int dateLeft;
		struct historyRec* next;
	};
};

Setting up players is working fine, i.e. making a new playerRec node and assigning each of the fields/elements and linking those to other playerRec nodes is fine, the problem i'm having however is creating a new node for the 'historyPtr' to point to, this may help you to understand what I'm saying:



I can create a new 'historyRec' node using;

struct historyRec* tmpPtr = new struct historyRec;

but when I try to tell 'historyPtr' (in my playerRec) to point to this new node using the following code:

startPtr->historyPtr = tmpPtr

I get the following error - "Cannot convert from struct Players::historyRec * to struct historyRec*"

Likewise when I try the following:

 startPtr->historyPtr = new struct historyRec;

Sorry if this is something really simple I have overlooked, I'm fairly new programming especially linked lists.

Can anyone see what I'm missing/doing wrong, any help would be greatly
appreciated, many thanks.
Kry1010 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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:56 AM.

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