Bear in mind, this code works in C#, but not in VC++.net (infuriating). I'm wondering where my mistake is on here.
Given the code:
public interface class iTest
{
public:
generic <typena开发者_StackOverflow社区me 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 the error error C3766: 'IUseInterface' must provide an implementation for the interface method 'void iTest::AddCriteriaList(System::Collections::Generic::List ^)'
The strange thing, is if I remove the generic constraint (Q) on IUseInterface, the error goes away. I don't understand how making my class generic would have ANYTHING to do with a generic on a specific function.
Any ideas? Thanks
Well, it seems to compile just fine if you don't use a List parameter, and just use a T parameter. Just use add them all in a loop or something, its a few lines of extra code, but will compile for you.
I don't have the answer for that, but this works, if it's good enough for you:
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)
{
}
};
精彩评论