PushDown Automata

I'm getting this annoying error and I have no idea why?????
LNK2019
Main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <string>
#include "PDATransition.h"
#include "PDA.h"
using namespace std;
void main()
{
string Q0 = "q0"; // start state
	string q[] = { "q0", "q1", "q2", "q3" }; // the exisiting state
	char s[] = { 'a', 'b', 'c', 'd' }; // the existing letters
	PDATransition t[] =
	{
		// startState, token, poped, pushed, endState
		PDATransition("q0", 'a', 'E', 'E', "q1"),
		PDATransition("q1", 'b', 'E', 'b', "q1"),
		PDATransition("q1", 'c', 'b', 'b', "q2"),
		PDATransition("q2", 'd', 'b', 'E', "q2"),
		PDATransition("q2", 'E', '$', '$', "q3"),
	}; // all exisint transitions
	string f[] = { "q3" }; // the final states

	/*this part don't change no matter what*/
	list<string> Q; // list of the states
	list<char> Sigma; // list of the letters
	list<PDATransition> Delta; // list of all avilable transitions
	list<string> FinalState; // list of all final states

	list<string>::iterator it1 = Q.begin(); // an iterator to save the states from the array to the list
	for (int i = 0, arraySize = sizeof(q) / sizeof(q[0]); i < arraySize; i++)
	{
		Q.insert(it1, q[i]); // inserting it into the list
	}

	list<char>::iterator it2 = Sigma.begin(); // an iterator to save the letters from the array to the list
	for (int i = 0, arraySize = sizeof(s) / sizeof(s[0]); i < arraySize; i++)
	{
		Sigma.insert(it2, s[i]); // inserting it into the list
	}

	list<PDATransition>::iterator it3 = Delta.begin(); // an iterator to save the letters from the array to the list
	for (int i = 0, arraySize = sizeof(t) / sizeof(t[0]); i < arraySize; i++)
	{
		Delta.insert(it3, t[i]); // inserting it into the list
	}

	list<string>::iterator it4 = FinalState.begin();
	for (int i = 0, arraySize = sizeof(f) / sizeof(f[0]); i < arraySize; i++)
	{
		FinalState.insert(it4, f[i]); // inserting it into the list
	}

	PDA x = PDA(Q, Sigma, Delta, Q0, FinalState);
	x.Accepts("abbbcddd");
}

PDATransition.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef PDATRANSITION_H
#define PDATRANSITION_H
#include <string>
using namespace std;

class PDATransition 
{
	public:
		// constractor
		/**
		* @string StartState: the start state of this transition
		* @char Token: the letter that is being taken from state to another
		* @char Poped: the letter that is being cheked inside the stack and getting out
		* @char Pushed: the letter that is being written to the stack
		* @string EndState: the end state of this transition
		*
		*/
		PDATransition(string startState, char token, char poped, char pushed, string endState);
		// destructor
		~PDATransition();
		// the same as toString function
		string toString();
		// get functions
		string getStartState();
		string getEndState();
		char getToken();
		char getPoped();
		char getPushed();
		// overloading the cout << operator to work as toString() function
		// and since it has been identified as a friend it will have access
		// to private members
		friend ostream &operator << (ostream &strm, const PDATransition &obj);
	private:
		// setting the main variables as private so no one would have access to them
		// except from the get functions
		string StartState; // the start state of this transition
		char Token; // the letter that is being taken from state to another
		char Poped; // the letter that is being cheked inside the stack and getting out
		char Pushed; // the letter that is being written to the stack
		string EndState; // the end state of this transition
		// the set function are also private because we don't want to change any of them
		// except inside the class functions
		void setStartState(string);
		void setEndState(string);
		void setToken(char);
		void setPoped(char);
		void setPushed(char);
};
#endif // !PDATRANSITION_H 

PDATransition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "PDATransition.h"
#include <string>
#include <iostream>
using namespace std;
// constractor
PDATransition::PDATransition(string startState, char token, char poped, char pushed, string endState)
{
	// setting the data
	StartState = startState;
	Token = token;
	Poped = poped;
	Pushed = pushed;
	EndState = endState;
}
// destructor
PDATransition::~PDATransition()
{
	// clearing all the variables after finishing with each one of them
	// memory managment
	StartState.clear();
	Token  = (char)0;
	Poped  = (char)0;
	Pushed = (char)0;
	EndState.clear();
}

void PDATransition::setStartState(string startState) 
{
	StartState = startState;
}

void PDATransition::setEndState(string endState) 
{
	EndState = endState;
}

void PDATransition::setPoped(char poped) 
{
	Poped = poped;
}

void PDATransition::setPushed(char pushed) 
{
	Pushed = pushed;
}

void PDATransition::setToken(char token) 
{
	Token = token;
}

string PDATransition::getStartState()
{
	return StartState;
}

string PDATransition::getEndState()
{
	return EndState;
}

char PDATransition::getToken()
{
	return Token;
}

char PDATransition::getPoped()
{
	return Poped;
}

char PDATransition::getPushed()
{
	return Pushed;
}

string PDATransition::toString()
{
	return "{(" + StartState + ")-(" + Token + ", " + Poped + ")->(" + Pushed + ")=>(" + EndState + ")}\n";
}
// the overloading cout operator 
ostream & operator<<(ostream & strm, const PDATransition & obj)
{
	strm << "{(" + obj.StartState + ")-(" + obj.Token + ", " + obj.Poped + ")->(" + obj.Pushed + ")=>(" + obj.EndState + ")}\n";
	return strm;
}

Stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef STACK_H
#define STACK_H
using namespace std;

template <class T>
class Stack 
{
	private:
		// structre for the stack node
		struct StackNode
		{
			T Value; // value in the node
			StackNode *next; // pointer to the next node
		};
		StackNode * top; // pointer to the stack top
	public:
		// constuctor
		Stack();
		~Stack();
		// stack operations
		void push(T);
		bool pop(T &);
		bool isEmpty();
		T getTop();
};

#endif // !STACK_H 

Stack.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "Stack.h"
using namespace std;

template <class T>
Stack<T>::Stack() 
{
	top = NULL;
}

template <class T>
Stack<T>::~Stack() 
{
	StackNode *nodePtr, *nextNode;
	// position nodePtr at the top of the stack
	nodePtr = top;
	// traverse the list deleting each node
	while (nodePtr != NULL) 
	{
		nextNode = nodePtr->next;
		delete nodePtr;
		nodePtr = nextNode;
	}
}

template <class T>
void Stack<T>::push(T item) 
{
	StackNode *newNode; // pointer to a new node
	// allocate a new node and store num there.
	newNode = new StackNode;
	newNode->Value = item;
	// if there are no nodes in the list
	// make newNode the first node.
	if (isEmpty()) 
	{
		top = newNode;
		newNode->next = NULL;
	}
	else // otherwise, insert NewNode before top
	{
		newNode->next = top;
		top = newNode;
	}
}

template <class T>
bool Stack<T>::pop(T &item)
{
	StackNode *temp; // temporary pointer
	// first make sure the stack isn't empty
	if (isEmpty())
	{
		return false;
	}
	else // pop value off top of the stack
	{
		item = top->Value;
		temp = top->next;
		delete top;
		top = temp;
		return true;
	}
}

template <class T>
bool Stack<T>::isEmpty()
{
	bool status;
	if (!top)
	{
		status = true;
	}
	else
	{
		status = false;
	}
	return status;
}

template<class T>
T Stack<T>::getTop()
{
	return top->Value;
}

please help in any way you can
Last edited on
You've promised to provide the definition of some function or object, but don't do so. The full text of the error, which you have neglected to share, should include the name of the function or object in question.
Topic archived. No new replies allowed.