.net with generic methods, implementation errors

Remember that this code works in C #, but not in VC ++. NET (infuriating). I wonder where my mistake is.

Based on the code:

public interface class iTest { public: generic <typename T> virtual void AddCriteriaList(List<T> ^CriterionList); }; generic <typename Q> public ref class IUseInterface : iTest { public: generic <typename T> virtual void AddCriteriaList(List<T> ^CriterionList) { } }; 

I get error C3766: "IUseInterface" should provide an implementation of the interface method "void iTest :: AddCriteriaList (System :: Collections :: Generic :: List ^)"

The strange thing is, if I remove the general constraint (Q) on the IUseInterface, the error will disappear. I don't understand how to make my generic class have ANYTHING to do with the general for a particular function.

Any ideas? Thanks

+4
source share
2 answers

Well, it looks like it compiles just fine if you don't use the List parameter, and just use the T. parameter. Just use them to add a few lines of additional code to the loop or something else, but compile for you.

+1
source

I have no answer for this, but it works if you have enough:

 generic <typename T> public interface class iTest { public: virtual void AddCriteriaList(List<T> ^CriterionList); }; generic <typename Q, typename T> public ref class IUseInterface : iTest<T> { public: virtual void AddCriteriaList(List<T> ^CriterionList) { } }; 
+1
source

All Articles