super constructors: I can't take it anymore!
nobody
nobody at mailinator.com
Wed Aug 16 08:29:28 PDT 2006
Serg Kovrov wrote:
> Here is my near-real class hierarchy:
>> class BaseWindow {
uint registerID; // inits to 0
>> this() {
if(registerID == 0) // nonzero registerID skips this step
{
registerID = register(...);
>> writefln("register BaseWindowClass");
}
>> writefln("create");
>> }
>> }
>> class FrameWindow : BaseWindow {
>> this(char[] caption) {
if(registerID == 0) // nonzero registerID skips this step
{
registerID = register(...);
>> writefln("register FrameWindowClass");
}
>> writefln("create %s", caption);
>> }
>> }
>> class MyFrameWindow : FrameWindow {
>> this(char[] caption) {
>> super(caption);
>> }
>> }
> What I want is that the only constructor called were
> FrameWindow.this(char[]), to have *only* this:
>> register FrameWindowClass
>> create test
I think caching some value which shows you have already registered should keep
any parents from registering again since the child's ctor should always be
called first.
More information about the Digitalmars-d-learn
mailing list