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


i'm getting error while attempting write program arduino. i'm novice @ c++ simple , obvious missing. attempting create simple templated linked list keep running issues. have following declared within own ino file in sketchbook. when attempt use linkedlistitem class, following error. if remove templating, still same error.

error: iso c++ forbids declaration of 'linkedlistitem' no type linkedlist:9: error: expected ';' before '<' token 

and 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 declaring pointer linkedlistitem this:

linkedlistitem<string>* _list; 

any appreciated.

you meant "string" instead of "string" std. after change, compiles. see working code below.

#include <string>  using namespace std;  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; }  int main() {     linkedlistitem<string>* _list;     return 0; } 

also, not typical implement linked list. besides, use corresponding linked list std unless have specific requirement have not yet mentioned.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -