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!