????????????д???????????????б??????????????????????
???????????????????????????????
??????????????????????£?
#ifndef CSTOCK_H_
#define CSTOCK_H_
typedef int elemType;
struct Item
{
elemType data;
Item * p_next;
};
class CStock
{
public:
CStock();
CStock(const CStock & otherStock); //??????????????
CStock & operator = (const CStock & otherStock); //=??????????
void push(elemType x);//?????????
bool pop(elemType &x); //?????????
bool isEmpty() const; //???????
void clear();//????????????
int size() const; //???????С??
void print() const; //??????????
~CStock();
public:
Item *p_Top;//???
};
#endif
??????????????????????£?
#include "CStock.h"
#include <iostream>
using std::cout;
using std::endl;
CStock::CStock(): p_Top(NULL)//??????
{
}
//?????????? ????????????????? CStock s1 = stock; ???????????????
CStock::CStock(const CStock & otherStock):p_Top(NULL)
{
*this = otherStock;
}
// =???????????????????磺CStock s1; .... CStock s2; s2 = s1;  ???????????????