Super confused, teacher says its obvious

Evening Everyone, I've been having issues, we got an assignment due in about a week or so and we have to alter a class and an application, basically all we have to do is create a copy constructor, a destructor, and overload the assignment operator... after doing these, I'm getting these weird repetitive errors. The "big three" were never fully explained by our teacher and everyone in the class seems to be behind and stuck,
I'm using g++ as a compiler and the error is

indexList.h:71: error: ISO C++ forbids in-class initialization of non-const static member `indexList<term>::size'
indexListApp.cpp: In function `int main()':
indexListApp.cpp:58: error: no matching function for call to `indexList<term>::indexList()'
indexList.cpp:22: note: candidates are: indexList<T>::indexList(const indexList<T>&) [with T = term]

And it just repeats with different lines... Normally our teacher is extremely helpful, but she took a look at it and said it should be obvious... I am COMPLETELY LOST... Everything else I said said to declare non const static member indexList<term>::size as a static member... i have no clue what that is... I put the full code at this link, if anyone has any ideas as to what the errors could mean, I would be incredibly grateful. I'll post the big three below

*An added detail, I've gathered that it might be talking about an object called size? or something of the like? anyway, there is no size in any of the files... at all... making it more confusing

//default constructor
template <class T>
indexList<T>::indexList()
{
numberOfElements = 0;
maxSize = 10;
}
//constuctor with parameters
template <class T>
indexList<T>::indexList(int value)
{
numberOfElements = 0;
maxSize = value; //value is the parameter passed for the size of the array
}

//copy constructor:
template <class T>
indexList<T>::indexList(const indexList& rhs)
{
maxSize = rhs.maxSize;
numberOfElements = rhs.numberOfElements;
list = new T[maxSize];
*this = rhs;//creates a deep copy
}

//overloading assignment operator
template <class T>
indexList<T>::operator=(const indexList& rhs)
{
if (this != &rhs);
{
maxSize = rhs.maxSize;
numberOfElements = rhs.numberOfElements;
delete[]list;
list = new T[maxSize];
for(int i = 0; i < maxSize; i++)
{
list[i] = rhs.List[i];
}
return *this;
}
}
Last edited on
> indexList.h:71: error
It's telling you that there is an error in the file `indexList.h' at line 71.
It may be a good idea to post that snip.

> ISO C++ forbids in-class initialization of non-const static member
Initialize it in the constructor instead.

> indexListApp.cpp:58: error: no matching function for call to `indexList<term>::indexList()'
You posted code that does have `indexList()' definition. I guess that you did not declare it.


By the way, you are missing return type in `operator='
Topic archived. No new replies allowed.