Object.factory create instance failed?
John C
johnch_atms at hotmail.com
Thu Jun 25 02:14:47 PDT 2009
Sam Hu Wrote:
>
> In below code snippet:
>
> class Dog
> {
> public void bark(){}
> }
> int main(string[] args)
> {
> auto obj=Object.factory("Dog");
> Dog doggie=cast(Dog)obj;
> doggie.bark;
>
> return 0;
> }
>
> Compiled successfully but failed when run:
> Object.Error:Access Violation.
>
> I also tried ClassInfo.find(string classname),ClassInfo.create() but caused the same error.
>
Object.factory requires a fully qualified class name, so if class Dog resides in module animals, call Object.factory("animals.Dog").
More information about the Digitalmars-d-learn
mailing list