Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 24, 2004 class construction bug? | ||||
---|---|---|---|---|
| ||||
I just tried this: class A { protected: this() { printf( "ctor\n" ); } } int main() { A a = new A(); } And it compiled and, when run, printed: "ctor." Is the "protected" keyword not working correctly or is there some rule that class constructors are inherently public? Sean |
February 24, 2004 Re: class construction bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Attributes are apparently applied at the module-level, rather than the class-level. "Sean Kelly" <sean@ffwd.cx> wrote in message news:c1ga1h$1c3d$1@digitaldaemon.com... > I just tried this: > > class A > { > protected: > this() { printf( "ctor\n" ); } > } > > int main() > { > A a = new A(); > } > > And it compiled and, when run, printed: "ctor." Is the "protected" keyword not working correctly or is there some rule that class constructors are inherently public? > > > Sean > |
February 24, 2004 Re: class construction bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | Kris wrote: >Attributes are apparently applied at the module-level, rather than the >class-level. > > > That is not true in this situation. Constructors are always public. >"Sean Kelly" <sean@ffwd.cx> wrote in message >news:c1ga1h$1c3d$1@digitaldaemon.com... > > >>I just tried this: >> >>class A >>{ >>protected: >> this() { printf( "ctor\n" ); } >>} >> >>int main() >>{ >> A a = new A(); >>} >> >>And it compiled and, when run, printed: "ctor." Is the "protected" >>keyword not working correctly or is there some rule that class >>constructors are inherently public? >> >> >>Sean >> >> >> > > > > -- -Anderson: http://badmama.com.au/~anderson/ |
February 24, 2004 Re: class construction bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote:
>
> That is not true in this situation. Constructors are always public.
Hm. So how would I go about creating a singleton or other class that has special construction requirements?
Sean
|
February 24, 2004 Re: class construction bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Sean Kelly wrote: > J Anderson wrote: > >> >> That is not true in this situation. Constructors are always public. > > > Hm. So how would I go about creating a singleton or other class that has special construction requirements? > > Sean I'm not exactly sure what you mean by special construction requirements. There was a whole discussion on singletons before, so you might what to look at that (using module-level or static members were suggested). Search for singletons. -- -Anderson: http://badmama.com.au/~anderson/ |
February 24, 2004 Re: class construction bug? | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote:
>
> I'm not exactly sure what you mean by special construction requirements. There was a whole discussion on singletons before, so you might what to look at that (using module-level or static members were suggested). Search for singletons.
Thanks. As for special construction requirements, I think that could all be handled by overloading "new." Just thinking out loud.
Sean
|
Copyright © 1999-2021 by the D Language Foundation