static vs non-static

Andrey andr-sar at yandex.ru
Sun Jan 13 09:59:27 PST 2013


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

}


More information about the Digitalmars-d-learn mailing list