class Parent {
int x;
alias x this;
}
class Child : Parent {
}
void main() {
Parent p = new Child;
Child c = cast(Child)p; // cannot cast `int` to `Child`
}
In this code, I got a compile error.
How can I cast p to Child?
class Parent {
int x;
alias x this;
}
class Child : Parent {
}
void main() {
Parent p = new Child;
Child c = cast(Child)p; // cannot cast `int` to `Child`
}
In this code, I got a compile error.
How can I cast p to Child?