0

How i can make the program recognize my operator << ??

#include <iostream>

using namespace::std;

template <class T>
class Set {
    T* group;
    int size_group;
public:
    Set():group(NULL),size_group(0){};
    Set(T*,int);
    Set(const Set<T>&);
    ~Set();

    void PrintObj()const;
    bool isThere(const T&)const;
    void getType()const;

    Set<T>& operator =(const Set<T>&);
    bool operator ==(const Set<T>&) const;
    void operator +=(const T);
    void operator -=(const T&);
    Set<T>& operator +(Set<T>&);
    Set<T>& operator -(const Set<T>&);
    bool operator >(const Set<T>&)const;
    friend ostream& operator << (ostream&,const Set<T>&);

};


template <class T>
ostream& operator << (ostream& output ,const Set<T>& obj){
    obj.getType();
    output << "The size of the group is: " << obj.size_group << endl;
    output << "{";
    for(int i=0; i < obj.size_group ; i++){
        output << obj.group[i];
        if(i+1 < obj.size_group){
            output << ", " ;
        }
    }
    output<< "}" << endl;
    return output;
}

MAIN:

#include "Set.h"

    int main() {
        int arr[] = {1,4,5,6,3,2};
        int arr2[] = {5,2,6};

        Set<int> j(arr,(sizeof(arr)/sizeof(arr[0]))),l(arr2,sizeof(arr2)/sizeof(arr2[0])),k;

        cout << j;
    }

When I try to call my print operator it doesn't recognize it

Showing Recent Messages Undefined symbol: operator<<(std::__1::basic_ostream >&, Set const&)

Lukas-T
  • 11,133
  • 3
  • 20
  • 30

0 Answers0