栈的实现,报错而我不知道为啥,请各位大神救救孩子吧

#include<iostream>
using namespace std;
int const  maxlen = 1000;
class stack {
public:
	stack();
	bool  empty()  const;
	bool full()   const;
	int  get_top(int& x)  const;
	int push(const int   x);
	int  pop();
private:
	int count;
   int date[maxlen];
};
stack::stack() {
	count = 0;
}
bool  stack::empty() const{
	if (count == 0)  return true;
	return false;

}
int  stack::get_top(int & x)const {
	if (empty())
		return -1;
	else {
		x=data[count - 1];
		return 0; 
	}
}
int  stack::push(const  int   x) {
	if (full())  return  -1;
	data[count] = x;
	count++;
	return  0;
}
int  stack::pop(){
	if (empty())  return  -1;
count--;
return 0;
}
bool  stack::full()const {
	if (count == maxlen)  return true;
	return  false;
}
void  read_write() {
	stack s;
	int n, x;
	cout << "please  input  num  int n";
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		s.push(x);

	}
	while (s.empty() != true) {
		s.get_top(x);
		cout << x;
		s.pop();
	}
}

data[count]和data[count-1]那里报错,我不知道为啥,求解,球球了

把错误信息贴出来看看,或者自己写打印语句看看变量的值,应该是数组越界了吧。

您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

速戳参与调研>>>https://t.csdnimg.cn/Kf0y

C和C++完整教程:https://blog.csdn.net/it_xiangqiang/category_10581430.html
C和C++算法完整教程:https://blog.csdn.net/it_xiangqiang/category_10768339.html