![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Location: UK
Posts: 3
Rep Power: 0
![]() |
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. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|