Say, classes A1,A2,…,An all extends the abstract class B.
I would like A1,…,An to have a function that returns a string of the class name.
This is certainly known in compile-time, but I would like to implement this function in
B, and use inheritance so that all Ai:s get this functionality.
In java, this can easily be done, by letting B have the method
String getName() {
return this.getClass();
}
more or less. So, how do I do this in D? Also, is there a way, using traits or similar, to determine which class members are public?
simply
typeof(this).stringofhowever this is fixed at compile time so inheritance doesn’t change the value
will give the dynamic name of the classname of the instance
http://www.d-programming-language.org/expression.html#typeidexpression
http://www.d-programming-language.org/phobos/object.html#TypeInfo_Class