相关疑难解决方法(0)

模板化运算符的奇怪行为<<

我无法理解我班上的operator <<的行为:

标题:

#ifndef VECTOR_H_
#define VECTOR_H_

#include <string>
#include <iostream>

template<class T>
class Vector {
        static const int EXPANDER = 10;
        T* array;
        int next;
        int length;
        void expand();
        void contract();
    public:
        Vector();
        Vector(const Vector& v);
        void add(const T e);
        T get(int index) const;
        bool removeByIndex(int index);
        bool remove(T e);
        int size() const;

        T operator[](int i) const;
        T& operator+=(const T& t);
        T operator+(const T& s);

        friend std::ostream& operator<< (std::ostream& os, const Vector<T>& obj);
        friend std::istream& operator>> (std::istream& is, Vector<T>& …
Run Code Online (Sandbox Code Playgroud)

c++ templates operator-overloading friend

0
推荐指数
1
解决办法
984
查看次数

标签 统计

c++ ×1

friend ×1

operator-overloading ×1

templates ×1