I'm having problems with Undefined Reference. Posted below is my code:
Code:
/* Stack.h - Stack Specification */
#include <stdlib.h>
#ifndef STACK_H
#define STACK_H
struct StackNode
{
int entry;
StackNode *next;
};
class Stack
{
public:
Stack();
void push(int data);
int pop();
int peek();
bool IsEmpty();
void test();
private:
StackNode *top;
int counter;
};
#endif
and the Stack.cpp file:
Code:
#include <stdlib.h>
#include <iostream.h>
#include "Stack.h"
Stack::Stack ()
{
counter = 0;
top = NULL;
}
void Stack :: push(int data)
{
StackNode *temp = new StackNode;
temp -> entry = data;
temp -> next = top;
top = temp;
counter++;
}
int Stack :: pop()
{
int dataHolder;
dataHolder = top -> entry;
top = top -> next;
return dataHolder;
}
bool Stack :: IsEmpty()
{
return (top == NULL);
}
int Stack :: peek()
{
return top -> entry;
}
void Stack :: test()
{
cout << "test";
}
and the Test.cpp with the main routine:
Code:
#include <stdlib.h>
#include <iostream.h>
#include "Stack.h"
main ()
{
Stack tester;
tester.test();
}
I keep getting "undefined reference to `Stack::Stack(void)' " errors.
I know I asked this in another thread of mine, but I didn't get much help... any help would be appreciated.