📄 array.h
字号:
#ifndef ARRAY_CLASS
#define ARRAY_CLASS
#include <assert.h>
template <class T>
class Array
{
private:
T *pList;
int nSize;
public:
Array(int size=50)
{
assert(size>0);
nSize=size;
pList=new T[nSize];
assert(pList!=NULL);
}
~Array()
{
delete []pList;
nSize=0;
}
T & operator[](int index)
{
assert(index>=0&&index<nSize);
return pList[index];
}
T & operator[](int index) const
{
assert(index>=0&&index<nSize);
return pList[index];
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -