一 代码
#include<algorithm>
#include<iostream>
#include <assert.h>
using namespace std;
template<typename T>
class myVector
{
private:
/*walk length*/
/*myVector each time increase space length*/
#define WALK_LENGTH 64;
public:
/*default constructor*/
myVector():array(0),theSize(0),theCapacity(0){ }
myVector(const T& t,unsigned int n):array(0),theSize(0),theCapacity(0){
while(n--){
push_back(t);
}
}
/*copy constructor*/
myVector(const myVector<T>& other):array(0),theSize(0),theCapacity(0){
*this = other;
}
/*= operator*/
myVector<T>& operator =(myVector<T>& other){
if(this == &other)
return *this;
clear();
theSize = other.size();
theCapacity = other.capacity();
array = new T[theCapacity];
for(unsigned int i


1万+

被折叠的 条评论
为什么被折叠?



