caffeine43
Registered Member
I have a question about a Linked-List structure...
I keep getting the error "request for member `AddFirst' in `abc', which is of non-aggregate type `List<int> ()()'"...It is really starting to aggrevate me because no matter what I change, it always is there.... except if I construct the List using a constructor other than the null constructor. All functions are declared in the class definition and the code for them is outside of the class. If anyone can help I would really really appreciate it...
Thanks a lot!
-Tom
Here's my happy little chunk of code that does nothing...
#include "list.h"
void main() {
List<int> abc();
abc.AddFirst(1);
}
And here's the function AddFirst, along with the null constructor...
template <class T>
List<T>::List()
{
head = tail = 0;
}
template <class T>
void List<T>::AddFirst (const T& a){
Node *newNode = new Node(a);
if(IsEmpty())
head = tail = newNode;
else
{
newNode -> next = head;
head = newNode;
}
}
I keep getting the error "request for member `AddFirst' in `abc', which is of non-aggregate type `List<int> ()()'"...It is really starting to aggrevate me because no matter what I change, it always is there.... except if I construct the List using a constructor other than the null constructor. All functions are declared in the class definition and the code for them is outside of the class. If anyone can help I would really really appreciate it...
Thanks a lot!
-Tom
Here's my happy little chunk of code that does nothing...
#include "list.h"
void main() {
List<int> abc();
abc.AddFirst(1);
}
And here's the function AddFirst, along with the null constructor...
template <class T>
List<T>::List()
{
head = tail = 0;
}
template <class T>
void List<T>::AddFirst (const T& a){
Node *newNode = new Node(a);
if(IsEmpty())
head = tail = newNode;
else
{
newNode -> next = head;
head = newNode;
}
}