Home

"Jess" <wdfcj@hotmail.com> wrote in message
news:1187617932.626353.64070@x35g2000prf.googlegroups.com...
> Hello,
>
> I learned that when I work with templates in C++, I should have
> functions that pass arguments by reference because the type of object
> is not known. Does it mean that if I have a function that is template
> function, then it's argument should be a reference type, such as the
> following?
>
> template<class T>
> void f(T& t){...}
>
> What if I replace the signature by
>
> template<class T>
> void f(T t){...}
>
> or
>
> template<class T>
> void f(T* tp){...}
>
> Would it work and if not, could someone tell me why please?

It would work the same way a function would work. So, yes, it would work
the because
void f(int* tp) {/*...*/}
would work.

previous
next

your opinion on book "Foundations of Python Network Programming"?
Re: GUI for viewing/editing python data structures?
Re: References or pointers?
Re: Pythonic way for missing dict keys
Re: How to declare stl iterator for a template type?
Mimo Wszystko
Niechciane i Zapomniane
Fundacja Avalon
Rodzic Po Ludzku
Akogo