Issues with List ADT, values not inserting

I'm working on a list adt that can have variables inserted and removed one at a time, it's controlled by a cursor that can be moved along the list.

I'm having an issue whenever I display the list, it's filled with '=' signs. I feel it has something to do with the default constructor, but even if I assign all the variables to '1' it still outputs '=' for all the items.

This is my code slightly modified so it'll be easier to understand. The constructor normally gets called and nothing is inserted into it (the insertion method takes care of that.) In this case, I had the constructor do the insertion and read out so I didn't fill my post with code.

Here's a piece of the code:
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
//Constructor
template < typename DataType >
List<DataType>::List(int maxNumber)
{
	cout << "Default constructor called, fill array with 1's" << endl;
	maxSize = maxNumber; 
	dataItems = new DataType[maxSize];
	size = maxNumber; //Normally set to 0 since default would be empty
	cursor = -1;     


//Fill List
	for (int j = 0; j < size; j++)
	{
		dataItems[j] = 1;  //Fill the list with 1's 
	}

	 
//Output List
	cout << "Display list: " << endl;
	for (int i = 0; i < maxSize; i++)
	{
	cout << dataItems[i];  //problem area, outputs '=' when 1's are expected

	}
}



I can post the rest of my code if need be, but I feel that my issue is the actual assignment of variables into the list itself. I think it's assigning whatever the ascii value for '=' not so much '=' itself.

If anyone could provide some insight, it would be much appreciated!
Last edited on
Is there a reason you aren't using the <list> function? Check it out here: http://www.cplusplus.com/reference/list/list/list/ If you aren't allowed to use this let me know and i'll look into what is going on.
Yeah, this is an exercise for class. We're given a header file along with a .cpp file with method declarations, our assignment is to put in the definitions. We're also given a test.cpp that utilizes these methods to check that they work.

Oddly enough, my insertions work fine, but these '=' signs keep popping up along with the values when I output the list. Doing some debugging, I found that the '=' are filling into the list upon construction.
Topic archived. No new replies allowed.