跪求C++小程序源代码

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:06:18
包含类就行了

//stack.h
#ifndef HEADER_STACK
#define HEADER_STACK
class Stack
{
int a[10];
int *p;
public:
Stack();
void pop(int e);
void push();
void putout();
};
#endif
//stack.cpp
#include"stack.h"
#include<iostream>
using namespace std;
void Stack::pop(int e){
if(p==(&a[9]+1)){ //warn!!!!!!!!!!!!!!!!!!
cout<<"it is upout."<<'\n'; //it is &a[9]+1
// cout<<p<<"\n"; //not &a[9]+4

}else{
*p=e;
++p;
// cout<<&a[9]+4<<"\n";
// cout<<p<<"\n";
}
}
void Stack::push()
{
--p;
if(p==(&a[0]-1)){
cout<<"it is tempy."<<"\n";

}else{
cout<<*p<<'\n';
}
<