I've recently began learning D, and furthermore templates. I wanted to make a small example to reinforce the reading, but then I get this error above.
Specifically for my code, it says:
using_point.obj(using_point)
Error 42: Symbol Undefined _D6points7_arrayZ --- errorlevel1
Here's my code:
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;
}
}
and main:
module using_point;
import std.stdio;
import point;
void main() {
byte[] mags = [1,2,3];
auto p1 = new Point!byte("P", mags);
}
I understand that it's a linking error, but since I'm not using external libraries and I think I've properly defined the constructor for Point, I can't seem to find the problem.
.to!stringcalls in your toString method. Everywhere where you try to appendthis.locations[N]to a string, you need to change it tothis.locations[N].to!stringif you want it to work with Type or T being anything else than string, char or (u)byte - WebFreak001