The purpose of my program is to have the user to enter a word to be checked to see if its a palindrome or not. My program works in Visual Basic...but i have to turn it in to my teacher through SSH. When I run my program there this is what i get....what is wrong?

-bash-3.00$ g++ palindrome_main.cpp
In file included from palindrome_main.cpp:21:
Queue.h:30:7: warning: no newline at end of file
Undefined                       first referenced
 symbol                             in file
Stack::pop(char&)                   /var/tmp//cc00NYD1.o
Queue::enqueue(char)                /var/tmp//cc00NYD1.o
Stack::push(char)                   /var/tmp//cc00NYD1.o
Queue::isEmpty()                    /var/tmp//cc00NYD1.o
Queue::Queue[in-charge]()           /var/tmp//cc00NYD1.o
Queue::~Queue [in-charge]()         /var/tmp//cc00NYD1.o
Stack::isEmpty()                    /var/tmp//cc00NYD1.o
Queue::dequeue(char&)               /var/tmp//cc00NYD1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

These are the files for the program that i transfered to SSH:

/*
	Name: Carien Anderson
	Program: Palindrome check
	
	This program check to see if the the user entered string is a palindrome (a word that can be reversed 
	and still read the same way).

	Stack s1 is a stack that will return the string backwards when popped to be compared to Queue q1 (a queue) which is read 
	the way in which it was typed in. equal is the function that compares eack stack and queue (which are dynamic) to see 
	if it is a palindrome. There are temp variables that will be used so send and get data from the stack/queue.

	Harships:
	My hardship was understanding how to create a dynamic stack and queue.

	There is a header file and cpp file for each stack and queue class which contain the operations for adding/removing data to/from 
	these dynamic structures. Each contatins a constructor and destructor as well. 
*/

#include <iostream>
#include "Stack.h"
#include "Queue.h"
#include <string>
using namespace std;
 
bool equal(Stack, Queue);

int main()
{
	Stack s1;
	Queue q1;
	string temp;
	char temp2;

	cout<<"Enter a string to check and see if its a palindrome: ";
	cin>>temp;

	int len = temp.length();

	for (int i = 0; i < len; i++)
	{
		temp2= temp[i];

		s1.push(temp2);
		q1.enqueue(temp2);
	}

	bool check = equal(s1, q1);

	if (check==true)
		cout<<temp<<" is a palindrome.";
	else
		cout<<temp<<" is not a palindrome.";

	cout<<endl;
	
	return 0;
}

bool equal (Stack s1, Queue q1)
{
	bool compare = true;

	char temp3, temp4;

	while(!s1.isEmpty() && !q1.isEmpty() && compare ==true)
	{
		s1.pop (temp3);
		q1.dequeue (temp4);

		if(temp3==temp4)
			compare=true;
		else 
			compare=false;
	}

	return compare;

}
 //Test runs

/*
Enter a string to check and see if its a palindrome: tattarrattat
tattarrattat is a palindrome.
Press any key to continue . . .
*/

/*
Enter a string to check and see if its a palindrome: america
america is not a palindrome.
Press any key to continue . . .
*/
#include <iostream>
#include "Queue.h"
using namespace std;

Queue::Queue()
{
	front=NULL;
	rear=NULL;
}

Queue::~Queue()
{
	clear();
}

void Queue::enqueue(char letter)
{
	if (isEmpty())
	{
		front = new QueueNode(letter);
		rear = front;
	}

	else
	{
		rear->next = new QueueNode(letter);
		rear = rear->next;
	}
}

void Queue::dequeue(char &letter)
{
	QueueNode *temp;

	if (isEmpty())
	{
		cout<<"The queue is empty.\n";
		exit(1);
	}

	else
	{
		letter = front->value;
		temp = front;
		front = front->next;
		delete temp;
	}
}

bool Queue::isEmpty()
{
	if(front == NULL)
		return true;
	else
		return false;
}

void Queue::clear()
{
	char value;

	while (!isEmpty())
		dequeue(value);
}
#ifndef QUEUE_H
#define QUEUE_H

class Queue
{
private:
	class QueueNode
	{
		friend class Queue;
		char value;
		QueueNode *next;
		QueueNode(char value1, QueueNode *next1 = NULL)
		{
			value = value1;
			next = next1;
		}
	};

	QueueNode *front;
	QueueNode *rear;

public:
	Queue();
	~Queue();
	void enqueue(char);
	void dequeue(char &);
	bool isEmpty();
	void clear();
};
#endif
#include <iostream>
#include "Stack.h"
using namespace std;

void Stack::push(char letter)
{
	top = new StackNode(letter, top);
}

void Stack::pop(char &letter)
{
	StackNode *temp;

	if (isEmpty())
	{
		cout<< "Stack is empty. \n";
			exit(1);
	}

	else
	{
		letter = top->value;
		temp = top;
		top = top->next;
		delete temp;
	}
}

bool Stack::isEmpty()
{
	if (!top)
		return true;
	else 
		return false;
}
#ifndef STACK_H
#define STACK_H

class Stack
{
private:
	class StackNode
	{
		friend class Stack;
		char value;
		StackNode *next;

		StackNode(char value1, StackNode *next1 = NULL)
		{
			value=value1;
			next = next1;
		}
	};

		StackNode *top;

public:
	Stack () {top = NULL;}
	void push (char);
	void pop (char &);
	bool isEmpty();
};

#endif

Recommended Answers

All 3 Replies

You didn't add QUEUE.CPP to your command line.

You didn't add QUEUE.CPP to your command line.

Not exactly sure what line you are referring too....the line where i run g++ or a line in the program?

Yes

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.