Template usage

I'm starting to use templates and i have written a general class that uses templates. Now i want to use a function that prints data from the class:
1
2
3
4
template <class T>
int output(const host<T> &amp){
//print data
}

Whenever i use this function i have to write:
1
2
3
host<int> amp;
//some stuff
std::cout << output<int>(amp) << std::endl;

My question is rather simple. Is there a way to let the function (output) deduce the type used in the class (amp)? I don't always want to write the output<int> part when it should be clear from the class because it is initialised as type int.

Hope it is clear what i mean. Thanks for answers in advance.
Last edited on
It works for me. What compiler do you use and what error message do you get if you leave out <int>?
I use the newest version of g++.
It says:
no matching function for call to 'func(output(host<int>::*amp))'


*edit* Nevermind i found the error it was a small typo. Its cool that the compiler gets it. :D

Thanks for the help and sorry.
Last edited on
Topic archived. No new replies allowed.