My code is posted below along with it's output of errors.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Node
{
public:
    string name;
    Node* north;
    Node* south;
    Node* east;
    Node* west;
};

class MazeConstructor
{
private:
    Node nodes[12];
public:
    Node* ConstructMaze();
};

Node* MazeConstructor::ConstructMaze()
{
    nodes[0] = Node("A");
    nodes[1] = Node("B");
    nodes[2] = Node("C");
    nodes[3] = Node("D");
    nodes[4] = Node("E");
    nodes[5] = Node("F");
    nodes[6] = Node("G");
    nodes[7] = Node("H");
    nodes[8] = Node("I");
    nodes[9] = Node("J");
    nodes[10] = Node("K");
    nodes[11] = Node("L");

    string filename;
    int index = 0;

    cout << "Please enter the name of the file:";
    cin >> filename;
    filename += ".txt";

    string tempString;
    ifstream inStream;

    //inStream.open(filename.c_str());
    //inStream.open("filename");
    int test = inStream.peek();

    while(!inStream.eof() && test != EOF)
    {
        getline(inStream, tempString);
        cout << tempString << endl;

        //The north connection
        string tempChar = tempString.substr(2,1);
        if(tempChar == "*")
        {
            Node temp("null");
            nodes[index].SetNorth(temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                {
                    nodes[index].SetNorth(nodes[i]);
                    cout << "Set north to: " <<nodes[i].GetName() <<endl;
                }
            }
        }

        //The east connection
        tempChar = tempString.substr(4,1);
        if(tempChar == "*")
        {
            Node temp("null");
            nodes[index].SetEast(temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetEast(nodes[i]);
            }
        }

        //The south connection
        tempChar = tempString.substr(6,1);
        if(tempChar == "*")
        {
            Node temp("null");
            nodes[index].SetSouth(temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetSouth(nodes[i]);
            }
        }

        //The west connection
        tempChar = tempString.substr(8,1);
        if(tempChar == "*")
        {
            Node temp("null");
            nodes[index].SetWest(temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetWest(nodes[i]);
            }
        }
    }

    inStream.close();
    Node* startNode;
    startNode = &nodes[0];
}

class Navigation
{
private:
    int stepsTaken;
public:
    Navigation(){ stepsTaken = 0;}
    void NavigateMaze(Node* startNode);
};

void Navigation::NavigateMaze(Node* startNode)
{
    bool finished = false;
    string direction;

    while(!finished)
    {
        cout << "GIMME A DIRECTION";
        cin >> direction;
        if(direction == "N")
        {
            cout << "Before" <<endl;
            startNode = startNode->GetNorth();
            cout << "After" <<endl;
        }
        else if(direction == "E")
            startNode = startNode->GetEast();
        else if(direction == "S")
            startNode = startNode->GetSouth();
        else if(direction == "W")
            startNode = startNode->GetWest();
        else if(startNode->GetName() == "L")
        {
            cout << "You finished!" << endl;
            finished = true;
        }
    }
}

int main()
{

    MazeConstructor mazeConstructor;
    Navigation mazeNavigator;

    Node* startNode = mazeConstructor.ConstructMaze();
    mazeNavigator.NavigateMaze(startNode);
    return 0;
}
Maze2.cpp:28: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:29: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:30: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:31: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:32: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:33: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:34: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:35: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:36: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:37: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:38: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:39: no matching function for call to `Node::Node (char[2])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:64: no matching function for call to `Node::Node (char[5])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:65: no matching function for call to `Node::SetNorth (Node &)'
Maze2.cpp:71: no matching function for call to `Node::GetName ()'
Maze2.cpp:73: no matching function for call to `Node::SetNorth (Node &)'
Maze2.cpp:74: no matching function for call to `Node::GetName ()'
Maze2.cpp:83: no matching function for call to `Node::Node (char[5])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:84: no matching function for call to `Node::SetEast (Node &)'
Maze2.cpp:90: no matching function for call to `Node::GetName ()'
Maze2.cpp:91: no matching function for call to `Node::SetEast (Node &)'
Maze2.cpp:99: no matching function for call to `Node::Node (char[5])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:100: no matching function for call to `Node::SetSouth (Node &)'
Maze2.cpp:106: no matching function for call to `Node::GetName ()'
Maze2.cpp:107: no matching function for call to `Node::SetSouth (Node &)'
Maze2.cpp:115: no matching function for call to `Node::Node (char[5])'
Maze2.cpp:16: candidates are: Node::Node(const Node &)
Maze2.cpp:16:                 Node::Node()
Maze2.cpp:116: no matching function for call to `Node::SetWest (Node &)'
Maze2.cpp:122: no matching function for call to `Node::GetName ()'
Maze2.cpp:123: no matching function for call to `Node::SetWest (Node &)'
C:\\Users\\Ryan\\Desktop\\OOP\\Maze2.cpp: In method `void Navigation::NavigateMaze(class Node *)':
Maze2.cpp:154: no matching function for call to `Node::GetNorth ()'
Maze2.cpp:158: no matching function for call to `Node::GetEast ()'
Maze2.cpp:160: no matching function for call to `Node::GetSouth ()'
Maze2.cpp:162: no matching function for call to `Node::GetWest ()'
Maze2.cpp:163: no matching function for call to `Node::GetName ()'

I've been trying to figure out for hours how to fix the errors but I haven't made any progress. I'm sure it's a simple fix but I'm new to c++ programming so I haven't came across one. Any help would be appreciated. Thanks!

The error messages are fairly straightforward: most of the member functions you are calling do not actually exist. You need to define and implement a constructor for Node which accepts a string as an argument, plus all of the member functions which you are using ( SetNorth() , etc).

I fixed the code with your suggestions and now I'm getting this error

Maze2.cpp:129: undefined reference to `MazeConstructor::Nodes(basic_string<char, string_char_traits<char>, __default_alloc_template<0, 0> >)'
Maze2.cpp:130: undefined reference to `MazeConstructor::Nodes(basic_string<char, string_char_traits<char>, __default_alloc_template<0, 0> >)'
Maze2.cpp:131: undefined reference to `MazeConstructor::Nodes(basic_string<char, string_char_traits<char>, __default_alloc_template<0, 0> >)'
Maze2.cpp:132: undefined reference to `MazeConstructor::Nodes(basic_string<char, string_char_traits<char>, __default_alloc_template<0, 0> >)'
Maze2.cpp:133: undefined reference to `MazeConstructor::Nodes(basic_string<char, string_char_traits<char>, __default_alloc_template<0, 0> >)'

here is my code

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Node
{
public:
    string name;
    Node* north;
    Node* south;
    Node* east;
    Node* west;
	      Node();
      Node(char data);
      void SetEast(Node EastNode);
      void SetSouth(Node SouthNode);
      void SetWest(Node WestNode);
      void SetNorth(Node NorthNode);
      Node* GetEast();
      Node* GetSouth();
      Node* GetWest();
      Node* GetNorth();
      string GetName();
      void SetName(char element2);
      void readMaze();
      Node* searchArray(Node* target);
      Node getCurrentRoom();
      int getNumMoves();
      string getDirections();
      void currentRoom();
      
      int counter;
      Node *array[12];
      //Node *east;
      string tempString;
      string filename;
      int numMoves;
      string directions;
      Node *northLinked, *southLinked, *eastLinked, *westLinked;
      Node *current;
      Node *finish;
      string element1;
      string element;
      //Node *south, *east, *west;
      int numSteps;
      string possibleWays;
      string currently, choice;
};

class MazeConstructor
{
private:
    Node nodes[12];
public:
    Node* ConstructMaze();
	 Node* Nodes(string);
	 string name;
	 
	 
};

Node::Node(char data)
   {
      element = data;
      north = NULL;
      south = NULL;
      east = NULL;
      west = NULL;
   }
    Node::Node()
   {
   }
    void Node::SetName(char element2)
   {
      element = element2;
   }
    string Node::GetName()
   {
      return element;
   }

 void Node::SetNorth(Node NorthNode)
   {
      north = &NorthNode;
   }
	
    void Node::SetSouth(Node SouthNode)
   {
      south = &SouthNode;
   }
	
    void Node::SetEast(Node EastNode)
   {
      east = &EastNode;
   }
	
    void Node::SetWest(Node WestNode)
   {
      west = &WestNode;
   }
	
    Node* Node::GetNorth()
   {
          
      return north;
   }
	
    Node* Node::GetSouth()
   {
      return south;
   }
	
    Node* Node::GetEast()
   {
      return east;
   }
	
    Node* Node::GetWest()
   {
      return west;
   }


Node* MazeConstructor::ConstructMaze()
{
    nodes[0] = *Nodes("A");
    nodes[1] = *Nodes("B");
    nodes[2] = *Nodes("C");
    nodes[3] = *Nodes("D");
    nodes[4] = *Nodes("E");
    nodes[5] = *Nodes("F");
    nodes[6] = *Nodes("G");
    nodes[7] = *Nodes("H");
    nodes[8] = *Nodes("I");
    nodes[9] = *Nodes("J");
    nodes[10] = *Nodes("K");
    nodes[11] = *Nodes("L");

    string filename;
    int index = 0;

    cout << "Please enter the name of the file:";
    cin >> filename;
    filename += ".txt";

    string tempString;
    ifstream inStream;

    //inStream.open(filename.c_str());
    //inStream.open("filename");
    int test = inStream.peek();

    while(!inStream.eof() && test != EOF)
    {
        getline(inStream, tempString);
        cout << tempString << endl;

        //The north connection
        string tempChar = tempString.substr(2,1);
        if(tempChar == "*")
        {
            Node* temp(NULL);
            nodes[index].SetNorth(*temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                {
                    nodes[index].SetNorth(nodes[i]);
                    cout << "Set north to: " <<nodes[i].GetName() <<endl;
                }
            }
        }

        //The east connection
        tempChar = tempString.substr(4,1);
        if(tempChar == "*")
        {
            Node* temp(NULL);
            nodes[index].SetEast(*temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetEast(nodes[i]);
            }
        }

        //The south connection
        tempChar = tempString.substr(6,1);
        if(tempChar == "*")
        {
            Node* temp(NULL);
            nodes[index].SetSouth(*temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetSouth(nodes[i]);
            }
        }

        //The west connection
        tempChar = tempString.substr(8,1);
        if(tempChar == "*")
        {
            Node* temp(NULL);
            nodes[index].SetWest(*temp);
        }
        else
        {
            for(int i = 0; i < 12; i++)
            {
                if(nodes[i].GetName() == tempChar)
                    nodes[index].SetWest(nodes[i]);
            }
        }
    }

    inStream.close();
    Node* startNode;
    startNode = &nodes[0];
}

class Navigation
{
private:
    int stepsTaken;
public:
    Navigation(){ stepsTaken = 0;}
    void NavigateMaze(Node* startNode);
};

void Navigation::NavigateMaze(Node* startNode)
{
    bool finished = false;
    string direction;

    while(!finished)
    {
        cout << "GIMME A DIRECTION";
        cin >> direction;
        if(direction == "N")
        {
            cout << "Before" <<endl;
            startNode = startNode->GetNorth();
            cout << "After" <<endl;
        }
        else if(direction == "E")
            startNode = startNode->GetEast();
        else if(direction == "S")
            startNode = startNode->GetSouth();
        else if(direction == "W")
            startNode = startNode->GetWest();
        else if(startNode->GetName() == "L")
        {
            cout << "You finished!" << endl;
            finished = true;
        }
    }
}

int main()
{

    MazeConstructor mazeConstructor;
    Navigation mazeNavigator;

    Node* startNode = mazeConstructor.ConstructMaze();
    mazeNavigator.NavigateMaze(startNode);
    return 0;
}

In the MazeConstructor class, you define a method named Nodes() (not the plural), but you never implement it anywhere. I suspect that what you actually want is the constructor for the Node class, however, which you do define (though incorrectly, I think - the data argument should be a string, not a single character).

On an unrelated note, I think you will want to change the definition of the nodes[] array to

Node * nodes[12];

This is because the individual elements of nodes[] has to hold a pointer to a Node , rather than a Node object. An even better solution might be to use a vector :

vector<Node*> nodes;

This takes away the size limit on the number of Node pointers.

I would also recommend separating the file into separate header and implementation files for the different classes, as this will make it much, much easier to read and reason about. You will need to have all of the different files together in a single Makefile or Project, depending on just what IDE and compiler you're using, but this isn't a very difficult process. For example, I'd previously taken earlier version of the Node class and broke it into a MazeNode.h header file and a MazeNode.cpp implementation file:

MazeNode.h

#ifndef MAZE_NODE_H
#define MAZE_NODE_H

#include <string>

class Node
{
private:
    std::string name;
    Node* north;
    Node* south;
    Node* east;
    Node* west;

public:
    Node(std::string n = " ");

    Node* GetNorth() { return north; };
    Node* GetSouth() { return south; };
    Node* GetEast()  { return east;  };
    Node* GetWest()  { return west;  };
    std::string GetName() { return name; };

    void SetNorth(Node *direction) { north = direction; };
    void SetSouth(Node *direction) { south = direction; };
    void SetEast(Node *direction)  { east  = direction; };
    void SetWest(Node *direction)  { west  = direction; };
};

#endif

MazeNode.cpp

#include <string>
#include "MazeNode.h"

Node::Node(std::string n): name(n)
{
    north = 0;
    south = 0;
    east = 0;
    west = 0;
}

These don't have the changes you've added, but you should be able to see the idea here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.