okie, i have this exact code..in Vis Studio
Code:
#include <iostreaM>
using namespace std;
template<typename Z>
struct Node
{
Z data ;
Node *next ;
Node(Z data, Node *next)
{
this->data = data ;
this->next = next ;
}
};
template<typename T>
class MyOwnStack
{
public:
void push(T x);
T pop() ;
MyOwnStack<T>();
private:
Node<T> *stackPtr ;
int index;
};
template<typename T> MyOwnStack<T>::MyOwnStack<T>()
{
stackPtr = NULL ;
}
template<typename T> void MyOwnStack<T>::push(T x)
{
Node<T> *t = stackPtr;
stackPtr = new Node<T>(x, t) ;
}
template<typename T> T MyOwnStack<T>::pop()
{
T t = stackPtr->data ;
Node<T> *d = stackPtr ;
stackPtr = stackPtr->next;
delete d;
return t;
}
int main()
{
MyOwnStack<int> myStack ;
myStack.push(10) ;
return 0;
}
but the problem is when i want to use .push(T x) it gives me ridiculous message
Code:
Error 1 error LNK2019: unresolved external symbol "public: void __thiscall MyStack<int>::push(int)" (?push@?$MyStack@H@@QAEXH@Z) referenced in function _main c:\Users\Eman\documents\visual studio 2010\Projects\TemplatedDataStructures\TemplatedDataStructures\main.obj TemplatedDataStructures
what on earth is happening?