Error: class myClass.myClass() is used as a type

Ali Çehreli acehreli at yahoo.com
Sun Jan 27 21:34:32 PST 2013


On 01/27/2013 12:13 PM, Daniel Kozak wrote:
 > On Sunday, 27 January 2013 at 19:55:07 UTC, rsk82 wrote:

 >> What's wrong here ?
 >
 > class myClass () {
 > this() {
 >
 > }
 > };
 >
 > should be
 >
 > class myClass {
 > this() {
 >
 > }
 > }

Yeah... Those empty parentheses were making myClass a class template, 
not a class. Apparently the syntax (or the compiler) allows template 
definitions without template parameters, which can still be instantiated:

class myClass () {
   this() {

   }
}

int main() {
     myClass!() my_instance = new myClass!();
   return 0;
}

Ali



More information about the Digitalmars-d mailing list