(未完成)
#include <iostream>>
using namespace std;
template <typename T> // 定义类模型
class Myvector
{
private:
T *first;
T *last;
T *end;
T &at(int pos)
{
return first[pos];
}
bool empty() // 判空
{
if (first == end)
return true;
return false;
}
bool full() // 判满
{
if (last == end)
return true;
return false;
}
T front() //
{
// 如果不为空,则返回值
if (empty())
{
/* code */
}
else
return *first;
}
T back() // 队尾
{
if (empty())
{
/* code */
}
else
return *last;
}
int size() // 返回大小
{
return sizeof(end - first) / sizeof(T);
}
void clear() // 清空
{
end = first;
}
void expand() // 二倍扩容函数
{
delete first;
}
void push_back(const T &temp)
{
if (first == nullptr) //
{
/* code */
}
}
public:
Myvector() {}
Myvector(T f, T l, T e) : first(new T(f)), last(new T(l)), end(new T(e)) {} // 有参构造
~Myvector() // 析构函数
{
delete first;
delete last;
delete end;
}
Myvector(&other) // 拷贝构造函数
{
*(this->first) = other;
}
Myvector &operator=(const Myvector &other) // 拷贝赋值函数
{
}
};
int main()
{
Myvector<int> a;
}