Hi all...
I tried to maked Stack with Dynamic Array but ........
class Stack
{
private:
int *SS;
int size;
int t;
void Expand();
public:
//constractors
Stack();
~Stack();
Stack(const Stack & Original);
//operations
Stack &operator= (const Stack& RHS);
bool Empty();
void Display();
int Pop();
void Push(int Value);
int Top ();
};
using namespace std;
#include "stdafx.h"
#include"stack.h"
#include<iostream>
Stack ::Stack ()
{
size=20;
SS=new int [size];
t=-1;
}
Stack ::Stack(const Stack &Original)
{
size=Original.size;
t=Original.t;
SS=new int [Size];
if(SS!=NULL)
{
for(int i=0 ; i<t; i++)
{
SS[i] =Original.SS[i];
}
}
}
bool Stack ::Empty()
{
return (t==-1);
}
void Stack ::Expand()
{
size=size*2;
int * SS_1=new int [size];
for(int i=0; i<t ; i++)
{
SS_2[i]=SS[i];
}
delete[]SS;
SS_2=SS;
}
Stack& Stack ::operator=(const Stack & RHS)
{
if(this != RHS)
{
if(size !=RHS.size)
{
delete[]SS;
size=RHS.size;
int * SS_2 = new int [size];
}
t=RHS.t;
for(int i=0 ; i<t; i++)
{
SS_2[i] = RHS.SS[i];
}
}
return *this;
}
void Stack :: Push(int Value)
{
if(t==capacity-1)
Expand();
t++;
SS[t]= Value;
}
int Stack :: Pop()
{
int V ;
if(!Empty())
{
V=SS[t] ;
t--;
return V ;
}
}
int Stack :: Top ()
{
if(!Empty())
return (SS[t]);
}
void Stack ::Display()
{
for(int i=0; i<t; i++)
cout<<SS[i]<<" ";
}
Stack ::~Stack()
{
delete[]SS;
}
succed when main is empty
#include "stdafx.h"
#include"stack.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
when i tried to write in main .......
#include "stdafx.h"
#include"stack.h"
int _tmain(int argc, _TCHAR* argv[])
{
Stack S;
return 0;
}
3_synatx error apper to me
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Stack::~Stack(void)" (??1Stack@@QAE@XZ) referenced in function _wmain Stack.obj
Error 2 error LNK2019: unresolved external symbol "public: __thiscall Stack::Stack(void)" (??0Stack@@QAE@XZ) referenced in function _wmain Stack.obj
Error 3 fatal error LNK1120: 2 unresolved externals E:\YOZOO\struct.prog\data structured\problems in c++\SecondYear\Stack\Debug\Stack.exe