关于类成员函数访问同类型外界数组的疑问
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复4
  • 已保存回复4
  • 发布时间2022/7/8 19:17
  • 上次更新2023/10/27 21:27:29
查看原帖
关于类成员函数访问同类型外界数组的疑问
595521
封禁用户楼主2022/7/8 19:17

假设:

class A {
private:
	int num;
public:
	A(int _num) { num = _num; }
	int getValue() {
		return num;
	}
	void getArrayElements(int i) {
		cout << a[i].getValue() << endl;  // ERROR HAPPENED HERE
	}
} a[114514];

代码在ERROR的地方报错,我该怎么让它访问a数组呢?

2022/7/8 19:17
加载中...