|
the first file:
class duizhan
{
public:
int stack[10];
int top;
int MaxSize;
duizhan();
~duizhan();
void push(int);
int pop();
};
the second file:
#include <iostream>
#include <stdio>
#include "duizhan.h"
using namespace std;
duizhan::duizhan()
{
int MaxSize = 10;
int top = -1;
}
void duizhan::push(int valve)
{
int i;
if (top>=MaxSize-1)
cout << "The stack is full!!!" << endl;
else
{
printf("\nThe stack content before(top -> bottom):");
for (i=top;i>=0;i--)
printf("[%d]",stack);
top++;
stack[top] = value;
printf("\nThe stack content after push(top -> bottom):");
for (i=top;i>=0;i--)
printf("[%d]",stack);
printf("\n");
}
}
int duizhan::pop()
{
int temp;
int i;
if (top<0){
printf("\nThe stack is empty!!!\n");
return -1;
}
printf("\nThe stack content before(top -> bottom):");
for (i=top;i>=0;i--)
printf("[%d]",stack);
temp = stack[top];
top--;
printf("\nThe pop value is [%d]",temp);
printf("\nThe stack content after pop(top -> bottom):");
for (i=top;i>=0;i--)
printf("[%d]",stack);
printf("\n");
return temp;
}
the third file:
#include "duizhan.h"
#include <iostream>
using namespace std;
int main()
{
duizhan dzh;
int select;
int stack[5];
int i,value;
printf("\n(1)Input a stack data");
printf("\n(2)Output a stack data");
printf("=n(3)Exit");
printf("\nPlease select one =>");
scanf("%d",&select);
do{
switch(select){
case 1:printf("\nPlease input the data=>");
scanf("%d",&value);
dzh.push(value);
break;
case 2:value=dzh.pop();
break;
}
printf("\n(1)Input a stack data");
printf("\n(2)Output a stack data");
printf("\n(3)Exit");
printf("\nPlease select one=>");
scanf("%d",&select);
printf("\n");
}while(select != 3);
}
the error view:
/tmp/cc72ZmlF.o(.text+0x19): In function `main':
: undefined reference to `duizhan::duizhan[in-charge]()'
/tmp/cc72ZmlF.o(.text+0xb7): In function `main':
: undefined reference to `duizhan::push(int)'
/tmp/cc72ZmlF.o(.text+0xc: In function `main':
: undefined reference to `duizhan::pop()'
/tmp/cc72ZmlF.o(.text+0x150): In function `main':
: undefined reference to `duizhan::~duizhan [in-charge]()'
/tmp/cc72ZmlF.o(.text+0x16d): In function `main':
: undefined reference to `duizhan::~duizhan [in-charge]()'
collect2: ld returned 1 exit status
how to do it now!!! :-( |
|