December 06, 2006 Documentation bug | ||||
---|---|---|---|---|
| ||||
The example given describing how to intialize a delegate type (found on http://www.digitalmars.com/d/type.html) will cause your executable to throw an access violation if you cut and paste it without modification. The problem is this line: OB o; I suspect (not being very familiar with the history of the language) that in the precambrian era, perhaps it was legal to declare an instance of a class this way (& get default construction), but that seems not to be the case anymore. The line really needs to be: OB o = new OB(); Tim Keating |
December 06, 2006 Re: Documentation bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tim Keating | Tim Keating wrote:
> The example given describing how to intialize a delegate type (found on
> http://www.digitalmars.com/d/type.html) will cause your executable to throw an
> access violation if you cut and paste it without modification.
>
> The problem is this line:
>
> OB o;
>
> I suspect (not being very familiar with the history of the language) that in
> the precambrian era, perhaps it was legal to declare an instance of a class
> this way (& get default construction), but that seems not to be the case
> anymore. The line really needs to be:
>
> OB o = new OB();
>
> Tim Keating
So far as I can recall we've never been able to declare-instantiate in this way, so its probably just a case of good old fashioned left-out-details in a sample snippet. But still, good catch -- I can imagine people trying to copy&paste it and getting frustrated.
-- Chris Nicholson-Sauls
|
Copyright © 1999-2021 by the D Language Foundation