Friday, 23 August 2013

Arduino error: ISO C++ forbids declaration of 'LinkedListItem' with no type

Arduino error: ISO C++ forbids declaration of 'LinkedListItem' with no type

I'm getting an error while attempting to write a program for an Arduino.
I'm a novice at C++ so this very well could be something simple and
obvious that I am missing. I am attempting to create a simple templated
linked list but keep running into issues. I have the following declared
within its own ino file in my sketchbook. When I attempt to use the
LinkedListItem class, I get the following error. Even if I remove the
templating, I still get the same error.
error: ISO C++ forbids declaration of 'LinkedListItem' with no type
LinkedList:9: error: expected ';' before '<' token
And the code:
template <class T>
class LinkedListItem {
public:
LinkedListItem(T value);
T getValue();
LinkedListItem<T>* getPreviousItem();
void setPrevious(LinkedListItem<T>* previous);
LinkedListItem<T>* getNextItem();
void setNext(LinkedListItem<T>* next);
private:
LinkedListItem<T>* _previous;
LinkedListItem<T>* _next;
T _value;
};
template <class T>
LinkedListItem<T>::LinkedListItem(T value) {
_value = value;
}
template <class T>
T LinkedListItem<T>::getValue() {
return _value;
}
template <class T>
LinkedListItem<T>* LinkedListItem<T>::getPreviousItem() {
return _previous;
}
template <class T>
void LinkedListItem<T>::setPrevious(LinkedListItem<T>* previous) {
_previous = previous;
}
template <class T>
LinkedListItem<T>* LinkedListItem<T>::getNextItem() {
return _next;
}
template <class T>
void LinkedListItem<T>::setNext(LinkedListItem<T>* next) {
_next = next;
}
I am declaring a pointer to a LinkedListItem like this:
LinkedListItem<String>* getCurrent();
Any help would be very much appreciated.

No comments:

Post a Comment