On Sunday, 9 August 2020 at 15:56:31 UTC, Ali Çehreli wrote:
On 8/9/20 7:27 AM, lexxn wrote:

I getClassById(uint id)
{
    if (id == 0) {
        return cast(A)Object.factory("deneme.A");
    } else if(id == 1) {
        return cast(B)Object.factory("deneme.B");
    } else {
        return cast(C)Object.factory("deneme.C");
    }
}

void main() {
  auto o = getClassById(1);
  o.methodName();
}

Ali

Btw is it possible to pass a property to the constructor, if I've one declared, in the factory? I'm talking about this piece cast(A)Object.factory("deneme.A")

Reply via email to