www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Converting some C++ code help.

reply "rookie" <rookie rooki.com> writes:
Hi,

I have the following C++ code, what would be the equivalent D 
code;

template <class T>
T Test<T>::pop(int ind)
{
     T pop = T();
     // Stuff that not important
     //....
     return pop;
}

Thanks,
rookie
Aug 02 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Thu, Aug 2, 2012 at 7:59 PM, rookie <rookie rooki.com> wrote:
 Hi,

 I have the following C++ code, what would be the equivalent D code;
IIRC, Test<T>::pop is a method definition, right ?
 template <class T>
 T Test<T>::pop(int ind)
 {
     T pop = T();
     // Stuff that not important
     //....
     return pop;
 }
in D, a free function would be: T pop(T)(int ind) { T pop; return pop; } and, in a class: class Test(T) { T pop(int ind) { T pop; return pop; } } But then, my C++ is quite rusty, some I'm sure there are some gotchas that I forgot.
Aug 02 2012