I am trying to write a scripted AI; and ran into this problem. In the following base class, how can I tell x that it can just as well expect a write reference?
class Node <T0, T1, T2> {
Node() {
// More missing non-relevance.
}
T0 write(T1 x) {
T0.write(x.read());
}
T0 write(T2 x) {
T0.write(x.read());
}
}
EDIT:
Here is the error:
Parser.java:181: cannot find symbol
symbol : method read()
location: class java.lang.Object
P.S. Or should I just do this in C++ function pointers.
In java you would need an Interface/class that has the read method. You ether use a standard one (perhaps x is an
OutputStreamimplementation?). Otherwise you would create your own interface. (Had to interpret a lot, but perhaps the code below is helpful)