On 8/9/20 10:27 AM, lexxn wrote:
On Sunday, 9 August 2020 at 12:24:05 UTC, Steven Schveighoffer wrote:
Object getClassById(uint id)
{
if (id == 0) {
return new A;
} else if(id == 1) {
return new B;
} else {
return new C;
}
}
I assume that the correct syntax for the getClassById is
Object getClassById(uint id) {
if (id == 0) {
return new A();
} else if (id == 1) {
return new B();
} else {
return new C();
}
}
or maybe I'm wrong.
If the constructor has no parameters, classes can be new'd without
parentheses, so your modification results in identical code as my example.
-Steve