I am writing a class template that contains an array of objects. I am getting an error that says "constructor syntax missing formal parameters". The error is associated with the line of code DT List[100];
template <class DT>
class List
{
private:
DT List[100];
int numberInList;
int listSize;
int nextIndex;
public:
List();
void insert(DT&);
DT getNext();
bool getMember(DT&);
int getNumber();
};
#endif
template<class DT>
List<DT>::List()
{
numberInList = 0;
listSize = 0;
nextIndex = 0;
}
For future readers (as noted by @UnholySheep in the comments), the problem most likely stemmed from the member DT List[100];. The name of the class is List as well as the name of the member. This likely caused some parsing confusion. Changing the name of the member variable should resolve the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With