Class knowing its own Class
    Tomek Sowiński 
    just at ask.me
       
    Wed Jun 30 13:59:50 PDT 2010
    
    
  
Dnia 30-06-2010 o 00:13:28 strtr <strtr at sp.am> napisał(a):
> == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
>> On Tue, 29 Jun 2010 17:59:37 -0400, strtr <strtr at sp.am> wrote:
>> > What is the pretty way to do something like this?
>> >
>> > Class C
>> > {
>> >   void makeNew()
>> >   {
>> >     new typeof(this);
>> >   }
>> > }
>> As edited...
>> -Steve
>
> Whahaha!
> Thanks, I knew I was missing something here.
Interestingly, this works even if makeNew is static (as factory methods  
usually are). Don't know whether by design or by bug. If by the latter,  
please don't fix it ;)
Tomek
    
    
More information about the Digitalmars-d-learn
mailing list