标签:div efi array set stat 定义 def clu bool
头文件:
#ifndef ZARRAY_H #define ZARRAY_H class ZArray { private: int *m_pointer; int m_length; public: ZArray(int length); ~ZArray(); volatile bool state; int length(); bool get(int index,int& value); bool set(int index,int value); }; #endif // ZARRAY_H
源文件:
#include "zarray.h" ZArray::ZArray(int length) { m_pointer = new int[length]; for(int i=0; i<length; i++) { m_pointer[i] = 0; } m_length = length; } ZArray::~ZArray() { delete m_pointer; } int ZArray::length() { return m_length; } bool ZArray::set(int index, int value) { bool ret=((0<=index)&&(index<length())); if(ret) { m_pointer[index] = value; } return ret; } bool ZArray::get(int index, int &value) { bool ret=((0<=index)&&(index<length())); if(ret) { value = m_pointer[index]; } return ret; }
使用:
ZArray zay(10); for(int i=0;i<zay.length();i++) { zay.set(i,i+1); } for(int i=0;i<zay.length();i++) { int value=0; if(zay.get(i,value)) { printf("a[%d]=%d\n",i,value); } }
标签:div efi array set stat 定义 def clu bool
原文地址:https://www.cnblogs.com/judes/p/9775742.html