私は最近、D、さらにはテンプレートを学習し始めました。私は読書を強化するための小さな例を作っていたが、私は上記のエラーを受けている。私のコードのための具体的Dlang Error 42:Symbol Undefined
、それは言う:
using_point.obj(using_point)
Error 42: Symbol Undefined _D6points7_arrayZ --- errorlevel1
ここに私のコードです:
module point;
class Point(Type: long) {
public string name;
public Type[] locations;
alias Type T;
this(string name, Type[] magnitudes) {
this.name = name;
for(int i = 0; i < magnitudes.length; i++)
locations ~= magnitudes[i];
}
override
public string toString() {
string output = this.name ~ " = (" ~ this.locations[0];
for(int i = 1; i < locations.length; i++)
output ~= "," ~ this.locations[i];
output ~= ")";
return output;
}
}
とメイン:
module using_point;
import std.stdio;
import point;
void main() {
byte[] mags = [1,2,3];
auto p1 = new Point!byte("P", mags);
}
は、私はそれがリンク誤りだということを理解しますが、以来、私は外部ライブラリを使用していないと私は適切にPointのコンストラクタを定義したと思う、私はpを見つけることができない汚れ。
あなたのコンパイルコマンドは何?あなたがdmd main.d point.dを一度にまとめて提出すれば、うまくいくはずです... –
これは答えではありませんが、いくつかの '.to!string'呼び出しが欠落していますtoStringメソッド。文字列に 'this.locations [N]'を追加しようとするところのどこでも、それがTypeまたはTが他のものとなるようにしたい場合は、this.locations [N] .to!string'に変更する必要があります文字列、charまたは(u)バイト – WebFreak001
私のコマンドは "dmd -c point.d"、 "dmd main.d"でした。ハァッ、奇妙。私はそれが輸入声明のために必要ではないと仮定した。そして、WebFreakに感謝します。私はそれを確実にします。私は実際にそれを計画し、ちょうどそれを離しました。あなたは必要な輸入声明を知っていますか? –