Добрый день! Возникла следующая проблема:
Есть класс, написанный на C#:
public abstract class ReadOnlyCollectionBase<T>: IList<T>
{
...
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator(); }
********************************************
void IList<T>.Insert(int index, T item) {
throw new NotSupportedException(); }
void IList<T>.RemoveAt(int index) {
throw new NotSupportedException(); }
void ICollection<T>.Add(T item) {
throw new NotSupportedException(); }
void ICollection<T>.Clear() {
throw new NotSupportedException(); }
bool ICollection<T>.Remove(T item) {
throw new NotSupportedException(); }
}
в котором, как видно, все неподдерживаемые методы интерфейсов IList<T> и ICollection<T> реализованы явно.
Далее создаю класс (C#), унаследованный от параметризованного ReadOnlyCollectionBase<T>:
public class PointsCollection : ReadOnlyCollectionBase<Point3D>
{
...
// Здесь переопределяю все, что мне нужно
...
}
Здесь все OK.
Но если такой же класс сделать на Managed C++:
public ref class PointsCollection : ReadOnlyCollectionBase<Point3D>
{
...
// Необходимые overrides
...
};
то компиляция заканчивается неудачей:
error C3766: 'PointsCollection' must provide an implementation for the interface method 'void System::Collections::Generic::ICollection<T>::Add(Point3D)'
error C3766: 'PointsCollection' must provide an implementation for the interface method 'void System::Collections::Generic::ICollection<T>::Clear(void)'
error C3766: 'PointsCollection' must provide an implementation for the interface method 'bool System::Collections::Generic::ICollection<T>::Remove(Point3D)'
error C3766: 'PointsCollection' must provide an implementation for the interface method 'void System::Collections::Generic::IList<T>::Insert(int,Point3D)'
error C3766: 'PointsCollection' must provide an implementation for the interface method 'void System::Collections::Generic::IList<T>::RemoveAt(int)'
Причем требует реализации только методов generic-интерфейсов (System::Collections::IEnumerable компилируется нормально).
Вопрос: почему так происходит, и как с этим бороться?
Заранее спасибо!