How to return a copy of the data in C++
I am trying to return a new copy of the data in a C++ Template class. The following code is getting this error: `invalid conversion from â€˜int*â€™ to â€˜intâ€™`. If I remove the `new T` then I am not returning a copy of the data but a pointer to it.

    template<class T>
    T OrderedList<T>::get( int k )
    {
        Node<T>* n = list;
        for( int i = 0; i < k; i++ )
        {
            n=n->get_link();
        }
        return new T( n->get_data() ); // This line is getting the error **********
    }
How to return a copy of the data in C++
===

I am trying to return a new copy of the data in a C++ Template class. The following code is getting this error: `invalid conversion from â€˜int*â€™ to â€˜intâ€™`. If I remove the `new T` then I am not returning a copy of the data but a pointer to it.

    template<class T>
    T OrderedList<T>::get( int k )
    {
        Node<T>* n = list;
        for( int i = 0; i < k; i++ )
        {
            n=n->get_link();
        }
        return new T( n->get_data() ); // This line is getting the error **********
    }