Demo entry 6659743

123

   

Submitted by 123 on Nov 12, 2017 at 13:59
Language: C++. Code size: 877 Bytes.

template <typename T>
class Vector
{
    T *data;
    int length;
public:
    Vector();
    Vector(int len);
    ~Vector();
    Vector(const Vector<T> &t);
    T &operator[](unsigned x);
    Vector &operator=(const Vector v);
    Vector operator+(const Vector v);
    Vector operator-(const Vector v);
    Vector operator*(const Vector v);
    Vector &operator+=(const Vector &v);
    Vector &operator-=(const Vector &v);
    Vector &operator*=(const Vector &v);
    Vector &operator++();
    Vector &operator--();
    Vector operator++(int);
    Vector operator--(int);
    T InnerProduct(Vector &v);
    double OuterProduct(Vector &v);
    Vector<T> & resize(int size);						// 调整向量的维数(可能需要改变资源容器的容量,须尽量保留原有数据)
    friend ostream & operator<< <T>(ostream &output,Vector<T> &v);
    friend istream & operator>> <T>(istream &input,Vector<T> &v);

};

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).