Compiler not recognizing the constructor [duplicate]

  c++, class, compiler-errors, constructor, templates

I’m trying to make a template class but for some reason the constructor isn’t being recognized. When I call the constructor with 2 values the compiler throws an error saying undefined reference.
i’ve been frustrated for a while now and can’t figure out what’s wrong. If anyone can help me it would be greatly appreciated
Here is the code:

Pair.h

#ifndef PAIR_H_INCLUDED
#define PAIR_H_INCLUDED
#include <iostream>
using size_t = decltype(sizeof 1);

namespace sdds
{
    template<typename K, typename V>
    class Pair
    {
    private:
        K k;
        V v;
    public:

        Pair(const K& key, const V& value);
        Pair() {}
        Pair(const Pair<K, V>& p);
        Pair<K, V> operator=(const Pair<K, V>& pair);
        const V& value() const;
        const K& key() const;
        void display(std::ostream& os) const;
    };

    template<typename K, typename V>
    std::ostream& operator<<(std::ostream& os, const Pair<V, K>& pair);
}

#endif // PAIR_H_INCLUDED

Pair.cpp

#include "Pair.h"

namespace sdds
{
    template<typename K, typename V>
    Pair<K, V>::Pair(const K& key, const V& value) //not being recognized
    {
        k = key;
        v = value;
    }

    template<typename K, typename V>
    Pair<K, V>::Pair(const Pair<K, V>& p)
    {
       k = p.k;
       v = p.v;
    }

    template<typename K, typename V>
    Pair<K, V> Pair<K, V>::operator=(const Pair<K, V>& pair)
    {
        k = pair.k;
        v = pair.v;

        return *this;
    }

    template<typename K, typename V>
    const K& Pair<K, V>::key() const
    {
        return k;
    }

    template<typename K, typename V>
    const V& Pair<K, V>::value() const
    {
        return v;
    }

    template<typename K, typename V>
    void Pair<K, V>::display(std::ostream& os) const
    {
        os << k << " : " << v << "n";
    }

    template<typename K, typename V>
    std::ostream& operator<<(std::ostream& os, const Pair<V, K>& pair)
    {
        pair.display();
        return os;
    }

}

main.cpp

#include "Pair.h"
int main(int argc, char* argv[])
{

    sdds::Pair<int, int> pair(56, 44); //thows error here

    return 0;
}

Error:

 undefined reference to `sdds::Pair<int, int>::Pair(int const&, int const&)'

Source: Windows Questions C++

LEAVE A COMMENT