Error del compilador C2108
el subíndice no es de tipo entero
Comentarios
El subíndice de la matriz es una expresión no entera.
Ejemplo
El error C2108 puede aparecer si utiliza incorrectamente el puntero this
de un tipo de valor para tener acceso al indizador predeterminado del tipo. Para obtener más información, consulte Semántica del puntero this
.
El ejemplo siguiente genera el error C2108.
// C2108.cpp
// compile with: /clr
using namespace System;
value struct B {
property Double default[Double] {
Double get(Double data) {
return data*data;
}
}
void Test() {
Console::WriteLine("{0}", this[3.3]); // C2108
Console::WriteLine("{0}", this->default[3.3]); // OK
}
};
int main() {
B ^ myb = gcnew B();
myb->Test();
}