#include <iostream>
#include <string.h>
#include <assert.h>
using namespace std;
#define DEFAULT_CAPACITY 3
typedef int DataType;
class Vector
{
public:
Vector()//构造函数
{
cout<<"Vector()"<<endl;
_size = 0;
_capacity = DEFAULT_CAPACITY;
_a = new DataType[_capacity];
}
//Vector(int size, DataType data)//有参构造
//{
// _size = size;
// _capacity = size + 20;
// _a = new DataType[_capacity];
// int i = 0;
// for(; i<_size; i++)
// _a[i] = data;
//}
Vector(const Vector& v)//拷贝构造函数
{
C++实现顺序表(vector相关操作的简单实现)
最新推荐文章于 2023-09-20 17:45:57 发布
本文详细介绍了C++中顺序表的实现,重点探讨了vector容器的基本操作,包括插入、删除、查找、遍历等常见操作,并通过实例代码进行解析,帮助读者深入理解C++标准库中的vector容器。
摘要由CSDN通过智能技术生成