-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
#include<iostream> | ||
#include<string> | ||
using namespace std; | ||
//只做声明 | ||
class myArray | ||
{ | ||
//权限 | ||
public: | ||
/*********行为*********/ | ||
myArray() ;//默认构造函数,可限制容量为100 | ||
myArray(int m_capacity);//有参构造函数,可以自定义容量 | ||
|
||
myArray(const myArray &p);//拷贝函数 | ||
|
||
~myArray();//析构函数 | ||
|
||
//尾插法 | ||
void pushback(int val); | ||
//设置对应位置数值 | ||
void SetData(int pos,int val); | ||
|
||
//获取对应位置数据 | ||
int GetData(int pos); | ||
//获取数组容量 | ||
int GetCapacity(); | ||
//获取数组大小 | ||
int GetSize(); | ||
//重载[] 运算符 | ||
int& operator[](int index); | ||
|
||
//属性 | ||
private: | ||
int m_Size;//数组大小 | ||
int m_Capaity;//数组容量 | ||
int *pAddress;//真实的在堆区开辟的数组的指针 | ||
}; |