www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - typedef-ed ctor

reply typedef d.com writes:
Suppose a class has ctor defined, then a typedef-ed class cannot use that ctor:
------------------------------------------------------------   
class A { public
this(int param) {} }    
 
typedef A B;    
 
#void foo() {    

A(0);  // OK    

expression    


------------------------------------------------------------   
 
by contrast,
if no ctor defined in A, then it works:
------------------------------------------------------------   
class A {}
typedef A B;    
 
void foo() {   
A a = new A();  //OK   
B b = new B();  //OK
}   
------------------------------------------------------------   
 
May 09 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

typedef d.com schrieb am Tue, 10 May 2005 02:00:09 +0000 (UTC):
 Suppose a class has ctor defined, then a typedef-ed class cannot use that ctor:
 ------------------------------------------------------------   
 class A { public
 this(int param) {} }    
  
 typedef A B;    
  
 #void foo() {    

 A(0);  // OK    

 expression    


 ------------------------------------------------------------   
  
 by contrast,
 if no ctor defined in A, then it works:
 ------------------------------------------------------------   
 class A {}
 typedef A B;    
  
 void foo() {   
 A a = new A();  //OK   
 B b = new B();  //OK
 }   
 ------------------------------------------------------------   
This is illegal code: http://digitalmars.com/d/class.html#constructors Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCgr903w+/yD4P9tIRAmD/AKDIMkyX2t4vBwebTvtYjGmEcfdLDACcCUxV Z58F8YAyPXK17lDQxlEtVXg= =l/k8 -----END PGP SIGNATURE-----
May 11 2005