Partilhar via


Erro do compilador C3915

'type' não tem nenhuma propriedade indexada padrão (indexador de classe)

Observações

Um tipo não tem uma propriedade indexada padrão.

Para obter mais informações, consulte propriedade.

Examples

O exemplo a seguir gera C3915.

// C3915.cpp
// compile with: /clr
ref class X {
public:
// uncomment property to resolve this C3915
//   property int default[]
//   {
//      int get(int i)
//      {
//         return 863;
//      }
//   }
};

int main() {
   X^ x = new X;
   System::Console::WriteLine(x[1]);   // C3915
}

C3915 também pode ocorrer se você tentar consumir um indexador padrão na mesma compilação e onde ele foi definido com DefaultMemberAttribute.

O exemplo a seguir gera C3915.

// C3915_b.cpp
// compile with: /clr
using namespace System;

[Reflection::DefaultMember("XXX")]
ref struct A {
   property Double XXX[Double] {
      Double get(Double data) {
         return data*data;
      }
   }
};

ref struct B {
   property Double default[Double] {
      Double get(Double data) {
         return data*data;
      }
   }
};

int main() {
   A ^ mya = gcnew A();
   Console::WriteLine("{0}", mya[3]);   // C3915

   B ^ myb = gcnew B();
   Console::WriteLine("{0}", myb[3]);   // OK
}