1

I have created a template class as following. I am new to this template concept.

template<class T>
class tem_class
{

private:
    T obj;
public:
    tem_class();
    void set_values(T x);
    T disp_fun();

};

Then I tried to invoke this class in Widget class.

void Widget::on_pushButton_clicked()
    {
       int a,b;
        a=5;
        tem_class<int> obj2 ;
        obj2.set_values(a);
        b = obj2.disp_fun();
    }

But I am getting following errors. error: undefined reference to tem_class<int>::tem_class() error: undefined reference totem_class::set_values(int) error: undefined reference to `tem_class::disp_fun() error: collect2: ld returned 1 exit status

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
Div
  • 11
  • 1

0 Answers0