using an object of a template class as a parameter

Hi,
I've written a template class:
1
2
3
4
5
6
7
template <typename T>
class example
{
    public:
        T value;
    ....
};


and I use an object of this class as a parameter of a function
1
2
3
4
int exampleFunc (example &input)
{
    return (int)input.value;
}


but what have I to do when I want to use the function with any object of example, I mean with example<double> same like with example<int> or anything else. The only idea i had was to overload the function with any possible datatype but that's not practical.

Has anyone an idea how it works?
Last edited on
The only idea i had was to overload the function with any possible datatype
1
2
template<typename T>
T exampleFunc (example<T> &input)
Last edited on
Topic archived. No new replies allowed.