generic question

G

Guest

For the following code

interface class I{};
public ref struct R1 : I
{
R1(R1%){}
R1(){}
};

generic <class T> // if you replace it with template, it works.
void f(T t)
{
I ^hi = t; // error in this line
}

int main()
{
R1 ^obj;
I ^hi = obj;
f(obj);
}

t.cpp
t.cpp(11) : error C2440: 'initializing' : cannot convert from 'T' to 'I ^'
No user-defined-conversion operator available, or
Conversion from generic type not allowed

If I replace generic with template it works fine. Can anyone tell what's
going on?
Thanks,
Kapil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top