Link-List with Nested Classes

Hi,

I asked for help on the forum earlier, I have since solved the original issue.

I need a little help in understanding how I would execute a nested class in a linked list... As example;

[Character][Weapon][Spell] classes are children of a [Base] class that stores normalized information such as 'Name'...

I am aiming to have a unique Character with a unique Weapon and Spell. I am trying to link-list these to have multiple characters. I just can't apply the design logic into programming logic, hopefully I'm making sense.

Thanks!

cNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once
#include "Includes.h"
class cNode
{
private:
	cNode* mpNext;
	int mObjectNumber;
public:
	cNode(int ObjectNumber);
	~cNode(void)
	{
		printf("Deleting node %d\n",mObjectNumber);
	}
	void AddLink(cNode *WhereToPoint)
	{
		mpNext = WhereToPoint;
	}
	int GetObjNum()
	{
		return mObjectNumber;
	}
	cNode *GetNextPtr()
	{
		return mpNext;
	}
};

cNode.cpp
1
2
3
4
5
6
7
8
9
#include "cNode.h"

cNode::cNode(int ObjectNumber)
{
	printf("Constructor called for node %d\n",ObjectNumber);

	mpNext = 0;
	mObjectNumber = ObjectNumber;
}

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "Includes.h"
#include "cNode.h"

using namespace std;

void main()
{
#define LIST_LEN 5

	cNode	*pHead		= NULL;
	cNode	*pCurrent;
	cNode	*pNode;
	int		ObjNum		= 0;

	for (int i = 0; i < LIST_LEN; i++)
	{
		pNode = new cNode(ObjNum++);

		if(!pHead)
		{
			pHead = pNode;	
                        pCurrent = pNode;
		}
		else
		{
			pCurrent->AddLink(pNode);
			pCurrent = pNode;
		} 
	}
}
Nevermind people I'll RTFM. Just done a bit more reading online about nested classes and I feel like a dope.

Ttfn.
Topic archived. No new replies allowed.