Does not name a type error in g++ relating to struct instantiation

  c++

I have some code here:

#include <vector>
#include <cstdio>


class Syntax {
  public:
    Syntax();
    ~Syntax();


    bool parseNext(int tokenID);

  private:

    struct Node {
      int token;
      std::vector<Node>* next;
    } none, wS1, lParen1, wS2, sub1, add1, div1, mul1, wS3, intLit, wS4, rParen1, endL;

    enum Tokens {
      WHITESPACE,
      ADD_OPERATOR,
      SUB_OPERATOR,
      MUL_OPERATOR,
      DIV_OPERATOR,
      L_PAREN,
      R_PAREN,
      INT_LITERAL,
      NONE
    };

    none.token = NONE;

};

That is giving me the error:

parser.hpp:32:5: error: ‘none’ does not name a type
   32 |     none.token = NONE;
      |     ^~~~
In file included from parser.cpp:1:
parser.hpp:32:5: error: ‘none’ does not name a type
   32 |     none.token = NONE;

      |     ^~~~

I do not know why. I checked online examples and it seems to match perfectly. In fact, I copied a struct from an online example and received the same errors. Can someone please help.

Source: Windows Questions C++

LEAVE A COMMENT