乞求大家看看这个顺序栈吧
//lrd.h
#ifndef LRD_H
#define LRD_H
#define NUM 10
#include <iostream>
class tack {
public:
double* stase;
double* top;
int sizeoftack;
tack(double* stase,double* top,int sizeoftack);
~tack();
}
#endif
//aa.h
#ifndef AA_H
#define AA_H
#include <iostream>
#include "lrd.h"
using std::cout;
using std::endl;
//得到一个栈的头元素
double GetTop(const tack& S) {
double e=0.0;
if(S.stase-S.top==0)
{if(S.stase==0)
cout<<"这是一个空栈!!!"<<endl;}
else e=*(S.top-1);
return e;
}
//压入栈
tack* Push(tack* T,double e) {
*(*T).top++ =e;
return T;
}
//删除栈
double Pop(tack* T) {
double e=0.0;
e= * --(*T).top;
delete (*T).(top+1);//我想删了top的上一个元素
return e;
}
#endif
//lrd.cpp
#include <iostream>
#include "lrd.h"
tack::tack(double* stase,double* top,int sizeoftack) {
stase=new double[NUM*sizeof(double)];
top=stase;
sizeoftack=NUM;
}
tack::~tack () {
delete [] stase;
delete [] top;
}
//main.cpp
#include <iostream>
#include <iomanip>
#include "lrd.h"
#include "aa.h"
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
int main() {
tack we;
tack* p=&we;
double ab[10]={12.36,56.23,78.25,89.123,45.789,58.369,1.2,3.6};
if(!we.stase) exit(1);
for(int i=0;i<=10;i++)
Push(p,ab[i]);
cout<<setprecision(8)<<fixed;
do{ i=0;i++;
cout<<Pop(p);
if(i%5==0) cout<<'\n';
else cout<<" ";
}while((*p).top==(*p).stase);
return 0;
}
这到底哪错了!!