Error del compilador C3070
'property': la propiedad no tiene un método 'set'
No se definió el método de descriptor de acceso set de una propiedad. Para obtener más información, consulta property.
El ejemplo siguiente genera la advertencia C3070:
// C3070.cpp
// compile with: /clr
ref class R {
public:
R(int size) {
m_data = gcnew array<int>(size);
}
property int % MyProp[int] {
int% get(int index) {
return m_data[index];
}
}
property int % MyProp2[int] {
int% get(int index) {
return m_data[index];
}
void set(int index, int % value) {}
}
property const int % MyProp3[int] {
const int% get(int index) {
return m_data[index];
}
void set(int index, const int % value) {}
}
private:
array<int>^ m_data;
};
int main() {
R^ r = gcnew R(10);
r->MyProp[4] = 4; // C3070
int value = 4;
r->MyProp2[4] = value; // OK
r->MyProp3[4] = 4; // OK
}