I'm having a hard time with an error that keeps popping up. It's a homework assignment and a large part of it is included in a separate .h file, so I won't post all the code to keep things intact. Here are the relevant parts:
//In the .h:
class array_list
{
private:
unsigned int * m_storage;
// points to current position in the list
// in documentation # marks the current position in the list
// ie. if l={#1,2,3} the 1 is the current position in the list
// if l={1,2,#3} the 3 is the current position in the list
// the # is ONLY for documentation purposes
unsigned int m_current;
unsigned int m_size;
unsigned int m_capacity;
// etc.
//Guide:
// Construct a new, empty list.
//
// Pre-conditions:
// none
// Post-conditions:
// m_storage is initialized to point to an array of size INIT_SIZE
// m_capacity is initialized to INIT_SIZE
// m_current is set to -1
// m_size is set to 0
//What I've written:
array_list::array_list()
{
int arrayOf[INIT_SIZE];
m_storage = arrayOf[]; /* <---THE PROBLEM LINE */
m_capacity = INIT_SIZE;
m_current = -1;
m_size = 0;
}
For some reason, I get the error that the compiler expected a primary-expression before the ']' token on the line indicated. I've been through my notes and done some Googling and it really does seem like this is the way to declare an array and point to it with a pre-defined pointer, no? Can anyone help me fix this? Thank you.