4
나는 D에 다음 코드를연관 배열 2.0
import std.stdio;
class Thing
{
// Fields
private string Name;
// Accessors
public string name() { return Name; }
}
class Place: Thing
{
// Fields
private Place[string] Attached;
// Modifiers
public void attach(Place place) { Attached[place.name()] = place; }
public void detach(Place place) { Attached.remove[place.name()]; } // error line
}
내가 dmd2.0으로 컴파일하려고 할 때마다 나는 다음과 같은 오류가 발생할 수
Error: function core.stdc.stdio.remove (in const(char*) filename) is not callable using argument types (Place[string])
Error: cannot implicitly convert expression (this.Attached) of type Place[string] to const(char*)
Error: remove((__error)) must be an array or pointer type, not int
현재 D2.0 설명서는 array.remove [key]를 사용하여 내가 수행하려고하는 것에 대해 조언하지만 컴파일러가 std.c (stdc?)를 호출하려고한다고 생각합니다. 기능. 왜 이런 일이 일어 났을까요? 이것은 dmd2.0의 버그입니까?
물론 신이 오. – Eli
정말 나쁜 오류 메시지입니다 : ... ( – BCS
예, 그렇습니다 .D가'a.fun'을 사용하여'fun (a)'형식의 함수를 호출 할 수있게하기 때문에 오류의 원인이 있습니다. 당신이'core.c.stdio.remove'를 호출하려고 시도하고 있다는 것을 추론함으로써 그곳에서 일하려고 시도합니다. –