c++实例代码附姐有解释.docVIP

  • 8
  • 0
  • 约2.43万字
  • 约 32页
  • 2018-12-22 发布于福建
  • 举报
c实例代码附姐有解释

第一题 #include iostream.h class Stack //定义堆栈类 { struct Node { int content; Node *next; } *top; public: Stack() { top = NULL; } // 构造函数的定义 bool push(int i); // 压栈成员函数的声明 bool pop(int i); // 弹栈成员函数的声明 }; bool Stack::push(int i) // 压栈成员函数的定义 { Node *p=new Node; if (p == NULL) { cout Stack is overflow.\n; return false; } else { p-content = i; p-next = top; top = p; return true; } } bool Stack::pop(int i) // 弹栈成员函数的定义 { if (top == NULL) { cout Stack is empty.\n; return

文档评论(0)

1亿VIP精品文档

相关文档