"OlgaM" <ol********@yahoo.com> wrote in message
news:37**************************@posting.google.c om...
Hello,
i'm trying to initialize an array.
The class List contains this in its private data members:
ListNode<DATATYPE> *dataItems;
In the constructor, i'm trying to allocate space for this array.
dataItems=new DATATYPE[maxNumber];
dataItems = new ListNode<DATATYPE>[maxNumber];
... and if you haven't done so already, don't forget to
create your copy constructor, assignment operator, and
destructor ("rule of three"), to do the 'delete[]'s
and/or reallocations. [1]
I'm getting the compiler error
'=' : cannot convert from 'int *' to 'class ListNode<int> *'
what am i doing wrong? Help please.
[1] You can preempt many headaches and bugs if you
use a container (e.g. a std::vector), instad of an array.
All the memory management would be done for you.
std::vector<ListNode<DATATYPE> > dataItems;
And unless you're making your own linked list
for learning purposes, you might consider using
the standard library's list class (which also
manages its own memory):
std::list<DATATYPE> dataItems;
HTH,
-Mike