static vs non-static
Zhenya
zheny at list.ru
Sun Jan 13 10:20:33 PST 2013
On Sunday, 13 January 2013 at 18:16:40 UTC, Zhenya wrote:
> On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote:
>> Don't know if this will be useful in any manner, but it came
>> this silly way:
>>
>> class MyClass {
>>
>> struct _static {
>>
>> static void myfun() {
>> writeln("static myfun");
>> }
>> }
>>
>> void myfun() {
>> writeln("myfun");
>> }
>>
>> }
>>
>> void main() {
>>
>> auto obj = new MyClass();
>> obj.myfun(); //myfun
>> obj._static.myfun(); //static
>> MyClass._static.myfun(); //static
>>
>> }
> Aha...Thank you,very interesting idea to hide function in
> struct:
>
>
> struct Foo
> {
> static struct bar
> {
> static void opCall()
> {
> writeln("static");
> }
> void bar()
> {
> writeln("non-static");
> }
> }
> }
>
> This is the workaround I looked for.
Oops...I made mistake:struct and function with the same name
isn't allowed.
Okay, I will try to get around it somehow...
More information about the Digitalmars-d-learn
mailing list