how to solve the error "Un defined reference in C++?

  c++, c++14

I’m trying to build a class template and everything looks fine but whenever I try to run the code, I run into this error "Un defined reference to ‘Yonah::Yonah(int, int)’"

####################################################################
Here’s my code
####################################################################

”’

#include <iostream>

using namespace std;

template<class T>

class Yonah
{
    T first, second;
    public:
        Yonah(T a, T b);
        T larger();

} ;

template<class T>

T Yonah<T>::larger()
        {
            return(first>second?first:second);
        }

int main()
{
    Yonah <int> obj(4,5);

    cout<<"Larger = "<<obj.larger();
    return 0;
}

”’

Source: Windows Questions C++

LEAVE A COMMENT