generic question

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Back
Top