2023年9月14日

仿照vector,编写自己的myvector

#include 

using namespace std;

template
class myvector
{
public:
    T *first;
    T *last;
    T *end;
public:
    //无参构造
    myvector()
    {
        first = new T[1];
        last = first;
        end=first+1;
        cout<<"无参构造"<=end)
        {
            mydouble();
        }

        for(int i=(last-first)+1;i>0;i--)
        {
            first[i]=first[i-1];
            if(i==n-1)
            {
                first[i]=e;
                return ;
            }
        }
    }

    //empty函数
    bool myempty()
    {
        if(last==first)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }

    void show()
    {
        for(int i=0;ive1(5,4);
    myvectorve2(ve1);
    int y;
    y=ve1.mycapacity();
    cout<

你可能感兴趣的:(c++)