Classes and @disable this()
Rene Zwanenburg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 8 09:32:55 PST 2015
On Sunday, 8 February 2015 at 16:28:21 UTC, fra wrote:
> On Sunday, 8 February 2015 at 16:22:36 UTC, fra wrote:
> Missclick... Anywya:
> class Something
> {
> @disable this();
> this(int i) {}
> }
>
> produces an undefined reference error.
>
> I guess it has to do with classes implicitly inheriting from
> Object, and Object defining a this(), and @disable telling the
> compiler not to produce code for the given function.
>
> However making it a compiler error would be far, far better
> then getting the linker error. In my case, the mangled name was
> 100% unintelligible (the usual "_ctor" was nowhere to be found,
> probably due to the class name being so long that it was
> getting shortened in some way)
No need to use @disable this(); A default constructor will only
be generated when you don't define a constructor yourself.
More information about the Digitalmars-d-learn
mailing list