0
int main()
 {
    Pair<int, int> A = makePair (10, 20);
    cout << A ;
 return 0;
}

it give me error here (makePair is not define) and i define it in header file

template<class T1, class T2>
class Pair{
private:
    T1 first;
    T2 second;
public:
    Pair(T1, T2);
    Pair() {};
    Pair<T1, T2>  makePair(T1  a, T2  b);
    void operator==(const Pair& other);
    friend ostream& operator<<(ostream& out, const Pair<T1, T2>& A);
};

and this is another file called pair.cpp that i used a template classes in it

template<class T1, class T2>
Pair<T1, T2> makePair(T1   a, T2   b)
{
    return (Pair<T1, T2>(a, b));
}

0 Answers0