Peppercat101 0 Newbie Poster

I have a slight problem, I have a dynamicSizeMatrix that has a member

ListAsLinkedList** theList;

Now this ListAsLinkedList can be either DLL or SLL, now it all works fine but when I add elements like this:

DynamicSizeMatrix hello(ListAsDLL(),5);
	hello.addToList(0,2,new Integer(10));
	hello.addToList(1,4,new Integer(6));
	hello.addToList(2,6,new Integer(8));
	hello.addToList(3,8,new Integer(7));
	hello.addToList(4,10,new Integer(7));
	cout<<hello<<endl;

then my output is:

NullObject NullObject 10
NullObject NullObject NullObject NullObject 6
NullObject NullObject NullObject NullObject NullObject 8
NullObject NullObject NullObject NullObject NullObject NullObject NullObject 7
NullObject NullObject NullObject NullObject NullObject NullObject NullObject NullObject 7

As you can see it adds it in the right index in some places but wrong in others. The loop that adds this looks as follows:

while((head+index-1) > tail)
		{
			
			cout<<i<<endl;
			i++;
			addToTail(NullObject::Instance());
		}
			addToTail(obj);

Any help?

P.S. Sorry if I dont ask this right or dont put in enough code, I dont use forums alot.