Im getting errors that i don't understand how to fix, any help would be greatly appreciated!

C:\MinGW\bin\g++ -pedantic -Wall -Wextra A9COPY.cpp -o A9COPY.exe
A9COPY.cpp:36: error: expected constructor, destructor, or type conversion before '*' token
A9COPY.cpp:44: error: expected unqualified-id before "void"
A9COPY.cpp:44: error: expected constructor, destructor, or type conversion before "void"
A9COPY.cpp:55: error: expected unqualified-id before "void"
A9COPY.cpp:55: error: expected constructor, destructor, or type conversion before "void"
A9COPY.cpp:68: error: expected unqualified-id before "bool"
A9COPY.cpp:68: error: expected constructor, destructor, or type conversion before "bool"
Exit code: 1

#include <iostream>
using namespace std;

class Node
{
   private:
      int val;
      Node* link;
   public:
      Node(){ val = 0;link = NULL;}
      int getVal(){return val;}//Accesor Functions
      Node* getLink(){return link;}
      void setLink(Node* p){link = p;}//Mutator Functions
      void setVal(int x){val = x;}
      //Node* getList(){return list;}
      //void setList(Node* p){list = p;}
};

class Set
{
   private:
        Node* list;
    public:
        Set() { list = NULL; }
      Node* cons(int x);
        bool member(int x);
      void print();
        //bool isEmtpy() const;
        //int size() const;
        //void insert(int x);
        //void remove(int x);
        ////friend const Set operator +(const Set& a,const Set& b);
        //friend const Set operator *(const Set& a,const Set& b);
};

Set::Node* cons(int x)
{
   Node* q = new Node;
   q.setVal(x);
   q.setLink(this);
   return q;
}

Set:: void print()
{
   cout << "{ ";
   while(this != NULL)
   {
      cout << this.getVal();
      this = this.getLink();
   }
   cout << " }\n";
}

Set:: void insert(int x)
{
   if(this.getList() == NULL || x < this.getVal() ){this.cons(x);}
   while(this.getList() != NULL)
   {
      this.setList(this.getLink);
      if(x < this.setLink)
      {
         this.cons(x);
      } 
   }
}

Set:: bool member(int x)
{
    while(this != NULL)
    {
        if(this.getVal() == x)
        { return true; }
    }
    this = (this.getLink());
   //list = cdr(list);
    return false;
}

int main()
{
   Set s;
   return 0;
}

Set::Node* cons(int x)

The proper syntax is

Node* Set:::cons(int x)

Similar for the other decleration as well.

This article has been dead for over six months. Start a new discussion instead.