Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

constructor syntax missing formal parameters

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;
}
like image 385
Jasmin Kenjar Avatar asked May 13 '26 07:05

Jasmin Kenjar


1 Answers

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.

like image 197
greg Avatar answered May 14 '26 21:05

greg